i want to validate data in form fields for firstName and lastName, how do i make a function to check the pattern when it includes letters, hyphens, spaces and apostrophes (') characters, i think that's all that would be in a person's name?
i have started with this but can't seem to get it to work with the hyphen!
function isLetters($element) {
return !preg_match ("/[^A-z]/", $element);
}
i also need to do one for phone numbers to make sure 10 digits are shown and that ( ) or - are not counted as one of the ten but are allowed in the field.
i just can't seem to get my head around how this works!!!
please help me!