SitePoint Sponsor

User Tag List

Results 1 to 5 of 5
  1. #1
    SitePoint Enthusiast
    Join Date
    Jul 2001
    Location
    East Side
    Posts
    98
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Validate and Goto

    Hi all!

    Well here is my problem. I am trying to write a script that when you would click on a button it would validate serveral text boxes in the form and send the user to a new url. My problem is that when I click on my submit button, it will validate the form and when I click "ok", automatically send the user to the next page. What I'd like to happen is if the text fields aren't filled in, a prompt comes up and says that they need to fill in certain boxes and when they click "ok" the page WILL NOT go to the next url but stay on the page until the user fills in all the necessary text boxes and then once all the boxes are filled in, and they click submit, the page will send them to the next url. Does that make sense? Can anyone offer any help?

    Thanks in advance!

  2. #2
    SitePoint Zealot Marek Bereza's Avatar
    Join Date
    Sep 2001
    Location
    London
    Posts
    129
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I don't really know, but maybe you could do this :
    Submit the form to the same page,
    and if textfields !="" then redirect.?
    of the brethren of disco metal
    Disco metal tunes at www.wikid.co.uk

  3. #3
    SitePoint Member
    Join Date
    Oct 2001
    Location
    tampa florida
    Posts
    3
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    hi,

    without seeing the code it's hard to figure, but it sounds like you're doing this:

    ##
    if (textfields not filled in){
    alert("message here")
    }
    ...
    submit.document.form1.blah
    ##

    when you might want to be doing this:
    ##
    if (textfields not filled in){
    alert("message here")
    }
    else{submit.document.form1.blah}
    ###

    the difference is simply that the submit doesn't happen unless the "textfields not filled in" condition doesn't apply.

    hope that solves it.

    -mupledge

  4. #4
    SitePoint Enthusiast
    Join Date
    Jul 2001
    Location
    East Side
    Posts
    98
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thanks all - I'll give it a shot.

  5. #5
    What? Maelstrom's Avatar
    Join Date
    Oct 2001
    Location
    Whistler BC originally from Guelph Ontario
    Posts
    2,175
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    The aboe solves the problem but this might add to your help

    if the person left his lastname empty

    if (document.formname.lastName.value == ""){
    alert('please fill out the form correctly')
    document.formname.lastName.focus()
    }

    that will return the focus back to the field in question
    Maelstrom Personal - Apparition Visions
    Development - PhP || Mysql || Zend || Devshed
    Unix - FreeBSD || FreeBsdForums || Man Pages
    They made me a sitepoint Mentor - Feel free to PM me or Email me and I will see if I can help.


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •