|
|
 |
RE: RE: FN-FORUM: javascript validation of phone numbers - allow spaces?
date posted 24th October 2006 15:58
quite right, the isNaN part just checks for anything non numeric
>
>I'm guessing it also doesn't work if you input your number like...
>+44 (0)1382 555666
>
>Cheers,
>Gary
>http://www.garyshort.org/
>
>
>> -----Original Message-----
>> From: [EMAIL REMOVED] [EMAIL REMOVED] On Behalf Of
>> [EMAIL REMOVED]
>> Sent: 24 October 2006 16:07
>> To: FN-FORUM / [EMAIL REMOVED]
>> Subject: FN-FORUM: javascript validation of phone numbers - allow spaces?
>>
>>
>> Afternoon all
>>
>> I'm trying to script a form validator in JS and I'm struggling with this
>final
>> part - validating phone numbers. Currently I'm using this (having set the
>> value of contactNumber previously)...
>>
>> if (contactNumber.value == "" || isNaN(contactNumber.value)) {
>> ErrorMsg.innerHTML = 'Please Enter a Telephone Number';
>> contactNumber.style.backgroundColor = '#FFD5D5';
>> return false;
>>
>> which throws an error if the number input box is blank or contains a non-
>> numeric char. I thought that was all I needed to do until I showed the
>client
>> and he entered his phone number with spaces! ack!
>>
>> could this be done with regular expressions? if so I'd really apreciate
>> someone telling me what the expression would be, I've neevr understood
>them.
>> Otherwise, how else can it be done?
>>
>> Thanks
>>
>> Chris
>>
>> --
>> Freelancers, contractors earn more with Prosperity4
>> Call 0870 870 4414 or visit www.prosperity4.com
>> and benefit from Inland Revenue approved expenses today.
>>
>> To advertise here: http://www.freelancers.net/advertising.html
>>
>>
>--
>Freelancers, contractors earn more with Prosperity4
>Call 0870 870 4414 or visit www.prosperity4.com
>and benefit from Inland Revenue approved expenses today.
>
>To advertise here: http://www.freelancers.net/advertising.html
>
> |
 |
|