The following example shows how to validate an entered email address.
On click of submit button js function Formsubmition is triggered which submits the form using Cold Fusion.
Ajax.submit Form method takes the values of all of the items in the form frm , and posts them to the file 'action.cfm.
The following code shows the implementation of this validate() function.
Now we will see how we can validate our entered form data before submitting it to the web server.
file A coldfusion structure named errors is created which will hold all the validation errors with key names equal to the div ids given in the form page under each input field.
This actually helps in populating data in to the corresponding divs.
Java Script provides a way to validate form's data on the client's computer before sending it to the web server. First let us see how to do a basic form validation.
In the above form, we are calling validate() to validate data when onsubmit event is occurring.
A Java Script check is useful because it stops the form from being submitted if there is a problem, saving lots of time for your readers.
The CGI script is still more reliable, as it always works regardless of whether Java Script is enabled on the client-side or not; but having this extra safety barrier is a nice thing to have in place.
content=ajaxdata_09As we are wrapping the Json string in epts a Java Script object, and returns a JSON string).