Im using the bassistance form validation. I have a couple of fields that require digits only, but that excludes symbols like $,(,),-,*, etc from being allowed and i need these for fields like prices and phone numbers. Anyone know a method or plugin or something to work around this?
UPDATE
Basically, i need a function that says “no text allowed” and allowed symbols and numbers.
Another update
Found a function that doesnt allow text alone. But if there are symbols, it allows text as well. Any way to restrict any text?
jQuery.validator.addMethod(
"symbols",
function(value,element){
var hNum=/[^a-z\s-]/;
var inp=jQuery.trim(element.value).toLowerCase();
if(hNum.test(inp)) { return true;
}
else return false;
},
"Number and symbols are only allowed."
);
According to their documentation, there’s already validation methods that can perform validation for: decimal numbers, digits and phone numbers
**EDIT: In that case it sounds like you want to create a custom validation. There is a method called addMethod which adds a custom validation with a call-back function like the one daGrevis created.
Example: