javascript - How can I fix my JS and jQuery to properly validate input? -
i brand new js , jquery. have written basic html form calculate values , wanting validate each input , test see if contains non-zero value can't figure out. have spent time searching before posting this. remember new take easy on me, please. here script test inputs.
$('#ppm_pt').on('change', function () { var input = $(this); var is_num = input.val(); if (is_num) { $('#calculate').prop("disabled", false) } else { $('#calculate').prop("disabled", true) } });
i can work check if there input ppm_pt, instead wanting check inputs of type number in html form , instead of checking value want test against nulls , 0 values. know there way. have tried using each() method unsuccessful. please help. thanks.
you doing id selection on element if form like:
$('#ppm_pt').on('change', 'input', function () { var input = $(this); var is_num = input.val(); if (is_num !== '') { $('#calculate').prop("disabled", true); } else { $('#calculate').prop("disabled", false); } });
Comments
Post a Comment