I have to prepare a small script that can disable button if input field is lower than number 1, and when the user presses the button while it is disabled he will get alert. Alert should be in content page, no popup. I prepared something like that:
<!-- language: lang-js -->
var toValidate = $('#inputName, #inputEmail, #inputTel'),
valid = false;
toValidate.keyup(function () {
if ($(this).val().length > 0) {
$(this).data('valid', true);
} else {
$(this).data('valid', false);
}
toValidate.each(function () {
if ($(this).data('valid') == true) {
valid = true;
} else {
valid = false;
}
});
if (valid === true) {
$('input[type=submit]').prop('disabled', false);
}else{
$('input[type=submit]').prop('disabled', true);
}
});
This code works very well, but it only works if there is any value in the input field. I can enter 0 and validation is passed, also i can't modify the code to display alert text if user click on disable button.