How to validate textbox for numbers and email using php (not java script) can anyone help me plz? And yes it is possible to see if first character of text box should be alphabet using php? Thank you
Check for digits (0-9) only: function checkDigits($element) { if(strlen ($element) > 0) { return !preg_match ("/[^0-9]/", $element); } return false; } Code (markup): Check for a valid email address: function checkEmail($email) { $pattern = "/^[A-z0-9\._-]+" . "@" . "[A-z0-9][A-z0-9-]*" . "(\.[A-z0-9_-]+)*" . "\.([A-z]{2,6})$/"; return preg_match ($pattern, $email); } Code (markup): I don't have one handy for first character of text has to be alphabet and I've got to run, but those two should help out.