skip to content »

Validating a submit request with javascipt

validating a submit request with javascipt-79

There are two ways to use an image instead of the button. You can use image input type to create a submit button.

validating a submit request with javascipt-53validating a submit request with javascipt-15

First, download the Java Script form validation script here. If this is possible with XMLHttp Request, it is not obvious. I need a solution that changes the location of the browser, just like submitting a form.The zip file contains the javascript file, examples.The script has a catalog of almost all the common validation types built-in.Using client side Java Script is an efficient way to validate the user input in web forms.

When there are many fields in the form, the Java Script validation becomes too complex.

And this should not be asynchronous, nor use XML, so Ajax is not the answer.

@mricci The point of this snippet is to redirect the browser to a new URL specified by the action; if you're staying on the same page you can just use traditional AJAX to POST your data.

Generally, a form is submitted when the user presses a submit button.

However, sometimes, you may need to submit the form programmatically using Java Script.

Since the post requires the "body" of the request to be a query-string formatted string, this allows your Ajax request to work properly as a post.