Answers for "check first two number jquery"

0

check first two number jquery

// Will work for " 123433 " or "12345634 ", etc.
var value = $(this).val(),
    re = /^\s*(\d{4})(\d+)\s*$/, // better to initialize only once somewhere in parent scope
    matches = re.exec(value),
    expectedCode = 3541,
    expectedLength = 13;
if(!!matches) {
    var code = matches[1]; // first group is exactly first 4 digits
    // in matches[2] you'll find the rest numbers.
    if(value.length == expectedLength && code == expectedCode) {
        // Change the color...
    }
}
Posted by: Guest on May-14-2020

Code answers related to "check first two number jquery"

Code answers related to "Javascript"

Browse Popular Code Answers by Language