...

View Full Version : Function to prevent numbers & @ sign



mark-new
03-02-2012, 01: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.

devnull69
03-02-2012, 02:00 PM
Example

HTML


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


Javascript


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

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

Many thanks

mark-new
03-02-2012, 03: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

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



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum