Function to validate CNIC using Regex

Solution In JQuery var checkCNIC = function (textBox) { debugger; var regexp = new RegExp('^[0-9+]{5}-[0-9+]{7}-[0-9]{1}$'); var check = textBox.value; if (!regexp.test(check)) { alert('Invalid CNIC'); $(textBox).css('border-color', 'red'); return false; } else { $(textBox).css('border-color', 'green'); $(textBox).value = check; return true; } } In HTML @Html.TextBox("AddCNIC", null, new { @class = "form-control text-box", @placeholder = "11111-1111111-1", @onchange =... Continue Reading →

Create a free website or blog at WordPress.com.

Up ↑

Design a site like this with WordPress.com
Get started