Home  |  About  | Last |  Submit  |  Contact
AllQuests.com



Previous Question:  Buttons and textarea  JavaScriptNext Question:  First party cookies implementation question  JavaScript
Question Validate and Goto ( SitePoint Forums JavaScript )
Updated: 2008-03-02 06:41:03 (4)
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!

Answers: Validate and Goto ( SitePoint Forums JavaScript )
Validate and Goto

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

Validate and Goto

Thanks all - I'll give it a shot.

Hundley

Validate and Goto

I don't really know, but maybe you could do this :
Submit the form to the same page,
and if textfields !="" then redirect.?

Marek Bereza

Validate and Goto

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

mupledge

Previous Question:  Buttons and textarea  SitePoint Forums  JavaScriptNext Question:  First party cookies implementation question  SitePoint Forums  JavaScript

- Source: Validate and Goto SitePoint Forums JavaScript
- Previous Question: Buttons and textarea SitePoint Forums JavaScript
- Next Question: First party cookies implementation question SitePoint Forums JavaScript