Allow Only Letters And Spaces - Jquery Validation Plugin June 25, 2024 Post a Comment I am validating a text field to allow only letters and spaces. This is the method I am using: jQuery.validator.addMethod('lettersonly', function(value, element) { return this.Solution 1: The regular expression is:^[a-z\s]*$ CopyLIVE DEMOSolution 2: jQuery.validator.addMethod("lettersonly", function(value, element) { returnthis.optional(element) || /^[a-zA-Z\s]*$/.test(value); },"Please enter only letters"); Copyreplace this : /^[a-z\s]+$/iby this :/^[a-zA-Z\s]*$/I checked It works. Share Post a Comment for "Allow Only Letters And Spaces - Jquery Validation Plugin"
Post a Comment for "Allow Only Letters And Spaces - Jquery Validation Plugin"