Click here to Skip to main content
15,913,669 members
Please Sign up or sign in to vote.
3.00/5 (1 vote)
See more:
i want to check validation on textbox for phone no entered or not?
if any one having any code pls forward it.
thanks in advance.
Posted

 
Share this answer
 
" phone no entered or not?"

Use the RequiredFieldValidator.

http://www.w3schools.com/aspnet/showasp.asp?filename=demo_reqfieldvalidator[^]
 
Share this answer
 
Try this one
C#
<asp:TextBox id="txtphone" Runat="server" />
<asp:RegularExpressionValidator id="RegularExpressionValidator1" runat="server"
ErrorMessage="In Valid phone no." ValidationExpression="^(?:[0-9]+(?:-[0-9])?)*$" ControlToValidate="txtphone" />
 
Share this answer
 
 
Share this answer
 
{
    if (!char.IsControl(e.KeyChar)
        && !char.IsDigit(e.KeyChar)
        && e.KeyChar != '.')
    {
        e.Handled = true;
    }

    if (e.KeyChar == '.'
     && (sender as TextBox).Text.IndexOf('.') > -1)
    {
        e.Handled = true;
    }
}
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900