File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes HTML, CSS and JavaScript and the fly likes anyone can help with alert in jscript ? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Engineering » HTML, CSS and JavaScript
Bookmark "anyone can help with alert in jscript ?" Watch "anyone can help with alert in jscript ?" New topic

anyone can help with alert in jscript ?


Joined: Jan 06, 2004
Posts: 8
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

Joined: Jan 10, 2002
Posts: 63838

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.
[ January 06, 2004: Message edited by: Bear Bibeault ]

[Asking smart questions] [About Bear] [Books by Bear]
Eric Pascarello

Joined: Nov 08, 2001
Posts: 15385
Basic idea
<form onsubmit="return Validate()">
fucntion Validate(){
return false;
return true
David Vickers

Joined: Oct 02, 2003
Posts: 13
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:
I agree. Here's the link:
subject: anyone can help with alert in jscript ?
It's not a secret anymore!