Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 5 of 5
  1. #1
    New to the CF scene
    Join Date
    Mar 2012
    Posts
    9
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Function to prevent numbers & @ sign

    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.

  • #2
    Senior Coder
    Join Date
    Dec 2010
    Posts
    2,391
    Thanks
    11
    Thanked 568 Times in 561 Posts
    Example

    HTML
    Code:
    <input type="text" name="description" value="" onchange="checkField(this);" />
    Javascript
    Code:
    function checkField(field) {
       if(/\d|@/.test(field.value)) {
          alert('Do not enter numbers or @ signs!');
          field.value = "";
       }
    }

  • #3
    New to the CF scene
    Join Date
    Mar 2012
    Posts
    9
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Thank you so much, I going to try it shortly and report back to you.

    Many thanks

  • #4
    New to the CF scene
    Join Date
    Mar 2012
    Posts
    9
    Thanks
    0
    Thanked 0 Times in 0 Posts
    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
    Attached Files Attached Files
    Last edited by mark-new; 03-02-2012 at 08:29 PM.

  • #5
    Senior Coder
    Join Date
    Dec 2010
    Posts
    2,391
    Thanks
    11
    Thanked 568 Times in 561 Posts
    PHP? You posted in the Javascript section


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •