Checking for special characters in a form field 
Author Message
 Checking for special characters in a form field

I have a form that asks for a users phone number.  I want all 10 digits, but
do NOT want any special characters such as ( or - or spaces.  I need a
script that when focus is moved away from that field it checks to see that
there are only 10 digits and none of those special characters.  I haven't
posted for a while and haven't had the time to check the thread for an
existing answer to this question.  I appologize if this may be a topic
already covered.

Thanks in advance,
Tom Moran



Sun, 27 Jun 2004 22:30:03 GMT  
 Checking for special characters in a form field


Quote:
> I have a form that asks for a users phone number.  I want all 10 digits

10 digits? but my phone number is 13 (and one of those is not a digit.)

Use regular expressions and check the .length

Jim.



Sun, 27 Jun 2004 22:33:19 GMT  
 Checking for special characters in a form field
Rather than test for invalid characters, why not just purge them? Here's an
input that will do just that:

<INPUT ONCHANGE="this.value=this.value.replace(/[^0-9]/g,'')">

Quote:

> I have a form that asks for a users phone number.  I want all 10 digits, but
> do NOT want any special characters such as ( or - or spaces.  I need a
> script that when focus is moved away from that field it checks to see that
> there are only 10 digits and none of those special characters.  I haven't
> posted for a while and haven't had the time to check the thread for an
> existing answer to this question.  I appologize if this may be a topic
> already covered.

--
Dave Anderson

Unsolicited commercial email will be read at a cost of $500 per message. Use of
this email address implies consent to these terms.



Mon, 28 Jun 2004 00:56:30 GMT  
 
 [ 3 post ] 

 Relevant Pages 

1. SubString: Checking for special characters

2. Special Characters in a Form

3. Illegal characters in form field names...

4. Illegal characters in form field names...

5. want to filter characters from form field

6. passing fields from form to form, and handling a date field

7. ? checking dynamically created form fields

8. Submit the form, how to check if required field is Not empty

9. Check to see if field is in FORM

10. special characters in ps

11. special characters

12. special character conversion

 

 
Powered by phpBB® Forum Software