0

I want to disable a login button, and enable only if the user has input correct number format with regex. This is not about the Regex issue. My problem is about the jQuery code is not working.

Here is my code:

$('#username').keyup(function () {
    var gval = $('#username').val();
    var re = new RegExp("^\s*(\+?\d{1,3})0*\d{2}[\s.-]?\d{3}[\s.-]?\d{3,4}\s*$");
    if (re.test(gval)) {
        $('#login-sms-btn').prop('disabled', false);
    } else {
        $('#login-sms-btn').prop('disabled', true);
    }
}); 

As I already apply disabled value to the button and hope to enable it when user input correct regex format. But it doesn't works.

Can anyone help to solve this please?

0 Answers0