View Full Version : Function to prevent numbers & @ sign

03-02-2012, 02:26 PM
Hello all,

Please I need help, I have a php form with different fileds. I have a field called description. The description field should only contains pure text, no numbers, but my users are entering phone numbers and email addresses into this field despite to the fact that there is already dedicated fileds for email and phone.

What I want is a javascript funtion or php function that will automatically delete the numbers or @ from the field or prevent entering numbers and @ signs on this particular field.

Many thanks in advance for your help.

03-02-2012, 03:00 PM


<input type="text" name="description" value="" onchange="checkField(this);" />


function checkField(field) {
if(/\d|@/.test(field.value)) {
alert('Do not enter numbers or @ signs!');
field.value = "";

03-02-2012, 03:20 PM
Thank you so much, I going to try it shortly and report back to you.

Many thanks

03-02-2012, 04:26 PM
Thanks again for the help but it gives me error in the php file. The field I want to control is the brief field. I have attached the form. Thanks again

03-03-2012, 11:05 AM
PHP? You posted in the Javascript section