Code Snippet:
//Block 1:
string strValidationFailureMessage =””;
if
(!IsNumeric(txtZipCode.Text.Trim()))
{
strValidationFailureMessage
= "Invalid Zip/Postal Code";
}
//Block 2:
private
bool IsNumeric(string
strData)
{
int i = 0;
bool blnIsNumber = true;
strData = strData.Trim();
//validation for Numeric Value
for (i = 0; i < strData.Length; i++)
{
blnIsNumber = char.IsDigit(strData[i]);
if (blnIsNumber == false)
{
break;
}
}
return blnIsNumber;
}
Note:
txtZipcode is the id of my textbox.
You can use Block1 in the beginning of your submit button and if string ‘strValidationFailureMessage’ is not empty then don’t proceed with saving or whatever you want to do inside buttonclick event. Display the message to user.

Srinivas MPosted Jan 6, 2015, 5:53 AM
ii have a confusion writing textbox valadition text sholud accept first character must me P and next 5 characters digits only and length is 6 please help me
Asad ButtPosted Aug 25, 2009, 6:56 AM
Hi, good job mate. What about RegExp in javascript ????