Pages

Manual verification of Validation Controls before getting submitted using Javascript

The Validation controls plays a major role in validation client data before it is getting posted in to the server. This is done by placing the appropriate validation controls required. This takes care of data validation before posting on its own. Suppose this same task has to handle even when validation controls are present. Let us see this.
A JavaScript function displayed below will takes care of a similar task.
function VerifyValidators()
{
//To verify the validators are passed in data validation.
//This Page_ClientValidate() function will return true if all the validation are passed else it returns false.
if (Page_ClientValidate() == true)
{
form1.submit();
}
}

The Page_ClientValidate() function will not be included in the page by default. To implement this function we need a minimum a single validation control. Then, this function is rendered as a part of any validation control by default. By using this function, we can check the Data Validation even before it gets posted to the server. Some times when using this functionality the page may not be posted to the server, then page has to be submitted to the server manually as given in the function or in any other way.

No comments:

Post a Comment