Validating input in java script
Checking for form completion: The first step of form validation is to check, whether the user have entered information in all the fields or not.
If the string value is numeric, it will return true, otherwise it will return false.
When the form is submitted - either by hitting Enter or clicking on the Submit button - the (the 'value' of the field called 'input' belonging to the form). In a real-life situation you will most likely have more fields to check, and more complicated conditions, but the principle remains the same.
Other form values are available using a similar syntax, although this becomes more complicated if you're using SELECT lists, checkboxes or radio buttons (see below for examples). All you need to do is extend the command is encountered, execution of the function is halted.
function form Validation() // Function that checks whether input text is numeric or not.
function text Numeric(inputtext, alert Msg) // Function that checks whether input text is an alphabetic character or not.
function length Define(inputtext, min, max) // Function that checks whether a option is selected from the selector and if it's not it displays an alert message.
function true Selection(inputtext, alert Msg) // Function that checks whether an user entered valid email address or not and displays alert message on wrong email address format.
escaping - by -) [0-9] : It matches digital number from 0-9. That means, you could be very sure about the form, whether users have entered the details or not.
Validation codes will return an alert message, if it finds some empty fields in the form.
If an user miss out any field, than the form will display error message.
You'll see that the all validation scripts presented on this and subsequent pages adhere to the same basic format.
Most modern browsers now support HTML5 Form Validation making it possible to validate form elements without (or before) any Java Script is triggered.
The value of a text input box (or a textarea or password input) is available using the syntax that tells you which option has been selected.