---------------Method 1
In .aspx Page:
--------------Method 2
function validNum(fld)
{
if(fld.value!='')
{
var id=fld.value;
var Reg=new RegExp("^[0-9]*\[0-9]$");
if(id.match(Reg)==null)
{
alert("Please Enter Numeric Values !");
fld.value='';
fld.focus();
return false;
}
if(id.indexOf("-")!=-1)
{
alert("Please Enter Positive Values !");
fld.value='';
fld.focus();
return false;
}
}
}
In .aspx.cs Page:
Text Box Name: txtCorpName
txtCorpName.Attributes.Add("OnKeyup", "Javascript:return(validNum(this));");
No comments:
Post a Comment