Search code examples
javascriptjquerylivevalidation

using livevalidation script - special characters except _ (underscore) - (hyphen) . (dot) and Space


I am using livevalidation script

http://livevalidation.com

I need to check whether the text contains special characters except _ (underscore) - (hyphen) . (dot) and Space Presence of special characters except those characters will not validated What Cain I do for this?


Solution

  • I think you are stuck with regular expression.

    The regular expression is for your requirement is /^[a-z0-9_ .-]*$/i

    var myField = new LiveValidation('myField', { validMessage: "I am valid!" });
    myField.add(Validate.Format, { pattern: /^[a-z0-9_ .-]*$/i });