Click here to Skip to main content
15,900,907 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
I have three textboxes.
In textbox1 and in textbox2 i entered a number Like ->
VB
Textbox1-0123456789
Textbox2-0123-456-789
Textboxe3-789-568-789



Now on server side i.e on aspx.cs page i need to check the numbers is it same or not and only one distinct number from textbox1 and textbox2 will be saved in database and Textboxe3 value will be saved because Textbox3 value is different
Posted
Updated 15-Mar-13 1:53am
v2
Comments
Sumit_Kumar_Sinha 15-Mar-13 9:00am    
you can use remov dash(-) and then simply compare the value of textbox1 and textbox2
Sandeep Mewara 15-Mar-13 10:34am    
Sounds straight forward. what is the problem? Where are you stuck?

1 solution

0 down vote accept


If we apply replace("-","") than from every textbox it will remove dash.The number which is same like in textbox1-0123456789 textbox2=0123-456-789 textbox3=678-908-999

than replace will remove dash from textbox3 also which we dont want. so For this we have to apply not exists operation of linq.

List strMobileNos = new List();

Regex re = new Regex(@"\d{10}|\d{3}\s*-\s*\d{3}\s*-\s*\d{4}");
!strMobileNos.Exists(l => l.Replace("-", "") == Request.Form["txtMobNo2"].Replace("Mobile2", "").Replace("-", ""))
 
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