Hey guys i have a Problem re-enabling my Button. I have 3 Inputfields which must be filled with value, if they are not filled by the user then the button is not clickable. So far so good but after the user puts something in, it should be re enabled but this step doesnt work. It works for single "Inputchecks" but not for all three, do you have a solution?
Code:
$('#uebung-hinzufuegen-hinzufuegen').prop('disabled',true);
$("#uebung-name, #uebung-date, #uebung-gewicht").each(function() {
if($(this).val().length !=0)
$('#uebung-hinzufuegen-hinzufuegen').prop('disabled',false);
})
This is not the proper way to implement jquery form validation.
You can achieve what you want, by accessing each input field, get the value and check. If any doesn't have a value, then you can enable.
$('#uebung-hinzufuegen-hinzufuegen').prop('disabled',false);
$("#uebung-name, #uebung-date, #uebung-gewicht").each(function() {
if($(this).val().length ==0)
$('#uebung-hinzufuegen-hinzufuegen').prop('disabled',true);
})
My suggestion though, would be to check jquery form validation for a proper implementation
Check an example here:https://www.tutorialspoint.com/How-to-validate-a-form-using-jQuery