aspose file tools*
The moose likes HTML, CSS and JavaScript and the fly likes Javascript validation 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 "Javascript validation" Watch "Javascript validation" New topic
Author

Javascript validation

Eduardo Bueno
Ranch Hand

Joined: Jun 04, 2009
Posts: 155
Hello ranchers,

I have an issue in my web application that is bugging me. I need to validate a form in which I have two buttons: confirm and cancel.

I'm using JSP. In the present moment, when the user clicks on 'confirm' button the onClick event is fired and calls a function to validate blank fields. The problem is that it causes a submit in the page, cleaning all fields' values. That's not friendly for the user.
Another way would be to validade blank fields in the onSubmit event of the form. Here is the other problem: how to avoid the 'cancel' button validating the fields? The only way to cancel the submit is in the onSubmit event returning false?

Thanks in advance.
Shailesh Narkhede
Ranch Hand

Joined: Jul 10, 2008
Posts: 365
onclick of confirm button when any feild is blank then show alert for that and from next line,
return;


Thanks,
Shailesh
Eduardo Bueno
Ranch Hand

Joined: Jun 04, 2009
Posts: 155
That worked, thanks.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Javascript validation
 
Similar Threads
cancel button issue
JavaSccript Validation API Needed & Issue with document.form.submit()
LookupDispatchAction + html:cancel
validate form fields using javascript in struts
How to stop the onclick function running when onsubmit validation fail