• Twitter
  • Facebook
  • Google+
  • Instagram
  • Youtube

Wednesday, August 8, 2007

Custom Validator with Javascript

Sample Example of Custom Validator to check Length of Textbox
=======================================================

1. Create Javascript function

function CheckLength(events, args)
{
var x = (document.getElementById(txtSKU).value);
if(x != '')
{
if(x.length < isvalid =" false;" isvalid =" true;">

2. Use one Custom Validator

EnableClientScript="true" Display="None" ClientValidationFunction="CheckLength"

3. Declare Variable in CS file

Page.ClientScript.RegisterStartupScript(this.GetType(), "CustomValidationTestForSKU", "var txtSKU='" + this.txtSKU.ClientID + "';", true);

0 comments:

Contact

Get in touch with me


Adress/Street

12 Street West Victoria 1234 Australia

Phone number

+(12) 3456 789

Website

www.johnsmith.com