How to give validations to mobile no,and email id,date of birth?

Posted by Tejamanimala under ASP.NET on 3/15/2013 | Points: 10 | Views : 1860 | Status : [Member] | Replies : 7
Hi,I have one registration form which is containg first name,last name,address,date of birth,gender,email id,i want give validation controls to it.i.e,for email id i want to add only example@gmail.com(gmail,hotmail,yahoo,like this),i dont want in the place of domain abc,lkkhj,only online accounts i want,and for contact no, i want to enter only numeric characters,and that to it should only accept the 10 digits,please can any reply to me for my requirement?.An i want validation for date of birth also.

manimala


Responses

Posted by: Chaithragm on: 3/15/2013 [Member] Starter | Points: 25

Up
0
Down
Use regularexpression validator
For phone
ValidationExpression="(([+]+[9]+[1]+[-]+)*)*\d{10}"
For Email
ValidationExpression="\w+([-+.']\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*"

Tejamanimala, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Tejamanimala on: 3/15/2013 [Member] Starter | Points: 25

Up
0
Down
thank you,and for date of birth i used text box only then,for d.o.b what validation should i use,i want only numeric,no characters,and the format should be,dd/mm/yy. can you please tell me

manimala

Tejamanimala, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Tejamanimala on: 3/15/2013 [Member] Starter | Points: 25

Up
0
Down
hi chaithragm,for phone,its not working,when i am entering 15 digits,its accepting 15 digits also,but i dont want that,and can you please check my source code....
<td class="style1">
<asp:TextBox ID="TextBox5" runat="server" Height="27px" Width="194px"
ToolTip="Enter ContactNo"></asp:TextBox>
</td>
<td class="style4">
<asp:RequiredFieldValidator ID="RequiredFieldValidator4" runat="server"
ControlToValidate="TextBox5"
ErrorMessage="Contact No should be numeric vallues,it allows only 10 digits"></asp:RequiredFieldValidator>
<asp:RegularExpressionValidator ID="RegularExpressionValidator2" runat="server"
ControlToValidate="TextBox5" ErrorMessage="*Invalid Contact No."
ValidationExpression="(([+]+[9]+[1]+[-]+)*)*\d{10}" ></asp:RegularExpressionValidator>

</td>

manimala

Tejamanimala, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Chaithragm on: 3/15/2013 [Member] Starter | Points: 25

Up
0
Down
<asp:RegularExpressionValidator ID="RegularExpressionValidator1" runat="server" ControlToValidate="txtContactNo" ErrorMessage="Enter Valid Contact Number" ForeColor="#F8F7DF" ValidationExpression="(([+]+[9]+[1]+[-]+)*)*\d{10}"></asp:RegularExpressionValidator>
<cc1:ValidatorCalloutExtender runat="server" TargetControlID="RegularExpressionValidator1"></cc1:ValidatorCalloutExtender>

i have checked its working if u type more than 10 digits also it will not accept it will give an error as Enter Valid Contact Number


you can limit to 10 digits by giving text box property maxlength=10 ;but problem is it wil not accept =+91

Tejamanimala, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Tejamanimala on: 3/18/2013 [Member] Starter | Points: 25

Up
0
Down

hi chaithragm,
what is this
<cc1:ValidatorCalloutExtender runat="server" TargetControlID="RegularExpressionValidator1"></cc1:ValidatorCalloutExtender>
am getting error here,what is the use of it?

manimala

Tejamanimala, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Tejamanimala on: 3/18/2013 [Member] Starter | Points: 25

Up
0
Down
can you please tell me the source code for date of the birth,it should be in the format of dd-mm-yyyy,it won't accept the format yyyy-mm-dd,or mm-yyyy-dd,plese tell me the code.

manimala

Tejamanimala, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Chaithragm on: 3/18/2013 [Member] Starter | Points: 25

Up
0
Down
<cc1:ValidatorCalloutExtender runat="server" TargetControlID="RegularExpressionValidator1"></cc1:ValidatorCalloutExtender>
am getting error here,what is the use of it?
this is Ajax extender ,i have used this to display a error message.u can remove this no problem


Tejamanimala, if this helps please login to Mark As Answer. | Alert Moderator

Login to post response