Hello friends, i need my telephone field of my form to accept only numbers and not alphabets & other characters, how do i do that?
regards
Page 1 of 1
how to make telelphone number field of my form accept only numbers
#2
Posted 14 March 2010 - 03:47 PM
I always used a jquery plugin - http://digitalbush.c...d-input-plugin/ - allows you put an input mask on fields.
However, this is only client side and you should be checking the input server side too.
However, this is only client side and you should be checking the input server side too.
#3
Posted 14 March 2010 - 04:49 PM
adsegzy, on 14 March 2010 - 03:45 PM, said:
Hello friends, i need my telephone field of my form to accept only numbers and not alphabets & other characters, how do i do that?
regards
regards
This is what I used:-
# elseif(eregi('[^][0-9]' , $rating))
# {echo "<p>Please only use numbers 0 to 9 inclusive.<br>Use your back button to <span style=\"color: red;\">try again</span>.</p>";}
The elseif may be different, it depends on the format of your PHP code.
[^] means NOT so it's checking if the input is not a number, if so, it shows the error text.
I also see that eregi is deprecated http://php.net/manua...ction.eregi.php but is still useable until PHP 6 (not released yet) when another function will have to be used (but I'm not sure which).
#4
Posted 16 March 2010 - 03:33 AM
Wickham, on 14 March 2010 - 04:49 PM, said:
I also see that eregi is deprecated http://php.net/manua...ction.eregi.php but is still useable until PHP 6 (not released yet) when another function will have to be used (but I'm not sure which).
preg_match()
http://php.net/manua....preg-match.php
Share this topic:
Page 1 of 1
Help
















