JavaScript Validations


Now we will learn here in JavaScript Tutorial that using of client side JavaScript is an efficient way to validate the user input in web applications. When there are many fields in the form, the JavaScript validation becomes too complex.

A person might think it easy to find a complete radio & checkbox client-side validation JavaScript on the web. It would however be our opinion that such a person would be mistaken. We searched and searched for a JavaScript We could plug and play, so to speak. The reality was, it simply did not exist. Here we define some common live JavaScript validation or what some might call inline error messages to explain more.

These are reusable JavaScript functions for common validations, here you will learn the list of built-in JavaScript functions to make any kind of Validations in JavaScript.
It includes things like checking if a value is a number, integer, blank, and so on…
It also has generic routines for getting and setting the value of any type of input field, as well as checking if the value has changed.

Functions used for JavaScript Validations

Function for JavaScript Validation

Description of validating function.

isBlank

This JavaScript will return True if the value is whitespace, newlines, or tabs. Otherwise it will return False.
Test Example of Is Blank in JavaScript.

isInteger

This JavaScript Function validated a number and returns True if the value is an integer, otherwise it will return False.

isNumeric

isNumeric validates the value of any variable and return True if the value is numerical value like (1.4, -4.56, etc), otherwise it will return False.

isDigit

idDigit Function validate a single character from 0-9 and return True if the value is a single character 0-9 else it returns False

setNullIfBlank

This setNullIfBlank JavaScript Function sets an input field’s value to empty if it only contains whitespace, newlines, or tabs

setFieldsToUpperCase

setFieldsToUpperCase JavaScript Function sets values of input fields to their uppercase values.

disallowBlank

disallowBlank JavaScript function returns true if field is blank, alerts a message, and focuses cursor to field requiring an input. Otherwise returns false.

disallowModify

disallowModify JavaScript Function returns true if field has been modified, alerts a message to visitor, and focuses cursor to field that was changed. Otherwise disallowModify returns false.

getInputValue

getInputValue JavaScript Function returns the value of any input element, regardless of type. getInputValue returns a comma-separated list for multiple selects and multiple form fields with the same name.

setInputValue

setInputValue JavaScript Function sets the value of any input element, regardless of type.

getInputDefaultValue

getInputDefaultValue JavaScript Function returns the default value at page load time of any input element, regardless of type. getInputDefaultValue returns a comma-separated list for multiple selects and multiple form fields with the same name.

isChanged

isChanged JavaScript Function returns true if the current value of a form field does not equal the value when the page was loaded.

Advertisements

~ by mjcprasad2000 on April 2, 2009.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

w

Connecting to %s

 
%d bloggers like this: