Author |
Topic |
rammohan
Posting Yak Master
212 Posts |
Posted - 2008-10-21 : 09:03:55
|
hi can anyone give me a function to validate indian mobile number ie it shud not exceed 14 chars and also it shud not be less than 10 digits n it can accept formats like this(+91)-9731324239731789889+91-9767767645One can never consent to creep,when one feels an impulse to soarRAMMOHAN |
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2008-10-21 : 09:06:08
|
Where do you want to get data from?If you use front end application, do this validation thereMadhivananFailing to plan is Planning to fail |
 |
|
rammohan
Posting Yak Master
212 Posts |
Posted - 2008-10-21 : 09:07:34
|
i am try to validate it at back end. i need to write a fucntion which will evaluates string based on this criteriaOne can never consent to creep,when one feels an impulse to soarRAMMOHAN |
 |
|
LoztInSpace
Aged Yak Warrior
940 Posts |
Posted - 2008-10-21 : 09:10:57
|
I disagree. Use a constraint using LIKE and any other string functions.You should never assume your client can reliably validate or clean up your data. |
 |
|
afrika
Master Smack Fu Yak Hacker
2706 Posts |
Posted - 2008-10-21 : 09:22:47
|
We have a bulk sms gateway that sends sms to numbers and they are all validate at the backend. We use a function to validate each country format passed to it.Funny, we got some tips from Madhivanan's blog on integer validation, the rest validates the length, starting character and network code |
 |
|
rammohan
Posting Yak Master
212 Posts |
Posted - 2008-10-21 : 09:55:14
|
Thanks for u r help, but i need to write a UDF for itOne can never consent to creep,when one feels an impulse to soarRAMMOHAN |
 |
|
LoztInSpace
Aged Yak Warrior
940 Posts |
Posted - 2008-10-21 : 09:58:35
|
well you are doing it wrong, but you can still write a function using LIKE and stuff. If you write the UDF you can and should add it as a constraint. Checkout the string functions in BOL. It's pretty straightforward. |
 |
|
rammohan
Posting Yak Master
212 Posts |
Posted - 2008-10-22 : 02:45:26
|
please, i want an UDF for this asapOne can never consent to creep,when one feels an impulse to soarRAMMOHAN |
 |
|
SwePeso
Patron Saint of Lost Yaks
30421 Posts |
Posted - 2008-10-22 : 03:51:22
|
quote: Originally posted by rammohan (+91)-9731324239731789889+91-9767767645
What is the correct way to format these three samples? E 12°55'05.63"N 56°04'39.26" |
 |
|
rammohan
Posting Yak Master
212 Posts |
Posted - 2008-10-22 : 06:11:23
|
it has to accept any of these three formats onlyOne can never consent to creep,when one feels an impulse to soarRAMMOHAN |
 |
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2008-10-22 : 07:59:48
|
One method isdeclare @data table(phno varchar(20))insert into @dataselect '(+91)-9731324283' union allselect '9731789889' union allselect '97(31)-789889' union allselect '91-9731789889' union allselect '(91)9731789889' union allselect '+9731789889' union allselect '+91-9767767645' select phno from @datawhere phno like '[(][+][0-9][0-9][)][-][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9]' orphno like '[0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9]' orphno like '[+][0-9][0-9][-][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9]' MadhivananFailing to plan is Planning to fail |
 |
|
|