How can I check whether input data is only in string format?

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • vbhavesht
    New Member
    • Jan 2013
    • 1

    How can I check whether input data is only in string format?

    i want to checked whether user entered data is only in character form..
    means user not allowed to enter numerical data into textfield.
    if user enter numerical data then give alert message.
  • Rabbit
    Recognized Expert MVP
    • Jan 2007
    • 12517

    #2
    This is not a code writing service but if you post the code you've tried along with a description of the problem, we can help guide you to an answer.

    Comment

    • Anas Mosaad
      New Member
      • Jan 2013
      • 185

      #3
      Code:
      var re = new RegExp('[U]^[A-Za-z]+$[/U]'); // change the regular expression to match your case
      var valueToCompare = document.getElementById('[U]YOUR ELEMENT ID[/U]').value;
        if (valueToCompare.match(re)) {
          alert("Successful match");
        } else {
          alert("No match");
        }
      }

      Comment

      Working...