Validating text fields in javascript

Rated 3.94/5 based on 690 customer reviews

You might like to open the source code for this form in a separate window, so that you can refer to it throughout the tutorial.You can see that the page consists of a Java Script function called That's all there is to simple Java Script form validation!Our example is very simple as it only checks one field.

Our validation script will ensure that the user enters their name before the form is sent to the server. Try pressing the Send Details button without filling anything in the "Your Name" field.

One point to note about Java Script validation is that it can always be circumvented by the user disabling Java Script in their browser, so for secure validation you'll need to write your validating code in your server-side scripts.

However, for day-to-day use Java Script is a quick and easy way to check over your forms before they're sent to your server.

Again, you might like to open the source code for this form in a separate window, so that you can refer to it as we talk you through.

Like our previous example, this page has a form called start at zero (for the first option).

Leave a Reply