Ashok N

Ashok N

  • NA
  • 8
  • 10.6k

Validating mobileNo.

Aug 11 2010 1:52 AM
In asp.net appln, I have a TextBox for mobile num with ID "txtMobileNo".
And the below JS function is assigned to Button as below:-
<asp:Button ID="Button1" runat="server" Text="Button" OnClientClick="ToCellValidate()"/>


function ToCellValidate()
{

var mob = document.getElementById(<%=txtMobileNo.ClientID%>").value;

if(mob !="")
{
var incomingString = mob ;
if(trimSpace(incomingString).length > 15 || incomingString.search(/[^0-9\-()+]/g) != -1 )
{
alert('Please enter valid mobile number');
txtMobileNo.focus();
txtMobileNo.value="";
return false;
}
else
return true;
}
}

Please tell me what is wrong with above JS function.

Answers (1)