• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

anyone can help with alert in jscript ?

 
svr
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have written a validation code in javascript. Gave an alert if the field is not valid. But after clicking the OK of the alert it submits the form. But in my case it shouldn't submit the form !.....please help me
Thanks for the help
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 65120
91
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ryan, thanks for changing your display name, but you didn't read the policy completely. Your display name must be a first and a last name separated by a space. Please try again.
With regards to your question, some code might help (please be sure to use UBB code tags to preserve formatting), but the most likely reason is that you are performing your validation in an onsumbit handler to your form (true or false?) which is not returning a value of false upon failure.
bear
[ January 06, 2004: Message edited by: Bear Bibeault ]
 
Eric Pascarello
author
Rancher
Posts: 15385
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Basic idea
<form onsubmit="return Validate()">
fucntion Validate(){
if(error){
return false;
}
else{
return true
}
}
 
David Vickers
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I agree with eric. I used the code below to check for empty fields. Also, it sends the user back to the offending piece too:
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic