Last active
March 20, 2021 13:28
-
-
Save MakkiAbid/5c41057e190232ae3cec7601ffa2ede8 to your computer and use it in GitHub Desktop.
Pakistan's CNIC Regex PHP
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// cnic check empty or valid | |
if (isset($_POST['cnic']) && !empty($_POST['cnic'])) { | |
if (preg_match('/^([0-9]{5})[\-]([0-9]{7})[\-]([0-9]{1})+/', $_POST['cnic'])) { | |
$cnic = clearInput($_POST['cnic']); | |
} else { | |
$cnic_error = '<p class="text-danger">Only numerics are allowed.</p>'; | |
} | |
} else { | |
$cnic_error = '<p class="text-danger">Field is not to be empty.</p>'; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment