only number validation
<script>
function checkForInt(evt)
{
var charCode = ( evt.which ) ? evt.which : event.keyCode;
return ( charCode >= 48 && charCode <= 57 );
}
</script>
onkeypress="return checkForInt(event)"
--------------------------------------------------
function checkForInt(evt)
{
var charCode = ( evt.which ) ? evt.which : event.keyCode;
return ( charCode >= 48 && charCode <= 57 );
}
</script>
onkeypress="return checkForInt(event)"
--------------------------------------------------
function checknum()
{
if((event.keyCode >=48 )&&(event.keyCode<=57))
{
return true;
}
else
{
alert("Please Enter Only Numeric Values..");
return false ;
}
}
onkeypress="return checknum();"
-------------------------------------------
function checklength(id)
{
if (id.value.length <11)
{
return chknum();
}
else
{
alert("Mobile Number cant not be greater than 11 Digits:::");
return false;
}
}
-------------------------------------------------
function blank()
{
if(document.getElementById("<%=TextBox1.ClientID %>").value=="")
{
alert("Cant be Blank not be blank!");
document.getElementById("<%=TextBox1.ClientID %>").focus();
return false ;
}
return true;
}
-----------------------------------------------------------------
Email Validations
function email()
{
var at="@"
var dot="."
var str=document.getElementById("<%=EmailIDTextBox.ClientID%>").value;
var lstr=str.length;
var lat=str.indexOf(at);
var ldot=str.indexOf(dot);
var pat=/^.+@.+\..{2,3}$/;
if(str.indexOf(at)==-1 ||str.indexOf(at)==0 ||str.indexOf(at)==lstr)
{
alert("Invalid EmailId..")
document.getElementById("<%=EmailIDTextBox.ClientID %>").focus();
return false;
}
if(str.indexOf(dot)==-1||str.indexOf(dot)==0||str.indexOf(dot)==lstr )
{
alert("Invalid EmailId..")
document.getElementById("<%=EmailIDTextBox.ClientID %>").focus();
return false;
}
return true ;
}
or
Email Validation
if(document.getElementById("<%=EmailTextBox.ClientID%>").value=="")
{
alert("Please Enter EMail Id....")
return false;
}
else
{
var at="@"
var dot="."
var str=document.getElementById("<%=EmailTextBox.ClientID%>").value;
var lstr=str.length;
var lat=str.indexOf(at);
var ldot=str.indexOf(dot);
var pat=/^.+@.+\..{2,3}$/;
if(str.indexOf(at)==-1 ||str.indexOf(at)==0 ||str.indexOf(at)==lstr)
{
alert("Invalid Email Id.. Please Try Again..")
return false;
}
if(str.indexOf(dot)==-1||str.indexOf(dot)==0||str.indexOf(dot)==lstr )
{
alert("Invalid Email Id.. Please Try Again..")
return false;
}
}
(both are same)
----------------------------------
function date()
{
if(document.getElementById("<%=.ClientID %>").value=="")
{
alert("Please Select The Date From Calendar");
return false ;
}
return true;
}
No comments:
Post a Comment