Validation Opencart
I want to add PHP phone number validation in an open cart code sample is given below
if(!filter_var($customer_email, FILTER_VALIDATE_EMAIL)) {
$errors[$pos++] = 'Email is not valid.';
}
if($customer_mobile=='') {
$errors[$pos++] = 'Please enter your Mobile.';
} /*elseif (strlen($customer_mobile) < 11 || !is_numeric($this->request->post['cell_number'])){
$errors[$pos++] = 'Mobile number should be 7 digits.';
}*/
Dominic
Well, you have 2 options, validate or filter. Because phone numbers are different in length and characters, what I would suggest is that you just filter
FILTER_SANITIZE_NUMBER_INT
Remove all characters except digits, plus and minus sign.