I have a validation algorythm (check by mask): 

```
function simpleval (selector,testexp) {         
        jQuery(selector).focusout (function() { 
            get_data = jQuery(this).val();
            test_data = get_data.search(testexp);
            if (test_data == -1){
                jQuery(this).attr('value', 'INCORRECT').css('color','red');
            }
            else {
                this.removeAttribute('style');
            }
            return (test_data);
        });
    }

```

To prevent user from clicking on "continue" button before the form is filled, i disable it:

```
        jQuery('#continue').attr('disabled', 'disabled');

```

Then I run check of the form:

```
        var tested_ip = /\b(([01]?\d?\d|2[0-4]\d|25[0-5])\.){3}([01]?\d?\d|2[0-4]\d|25[0-5])\b/;
        ip_test = simpleval ("#dbAddress",tested_ip);
        var tested_port = /\d{2,}/; 
        port_test = simpleval("#dbPort",tested_port);

```

Now if both fields (IP and port #) are filled correctly i have to enable "continue" button.

```
function buttonState(){
    var isValid = false;
    if(ip_test=='0' && port_test=='0') {
                    isValid = true; 
        }
    if (isValid) {
                jQuery('#continue').attr('disabled', '')
                replaceText ('#msg','IT WORKS');
            }
    else jQuery('#continue').attr('disabled', 'disabled');
        }

    jQuery('input').on('focusout', buttonState)

```

What's wrong with it: everything works fine, but the button is still disabled.