I have a plugin translate page: In this page I insert a row of flags and a form with original text of post and inputs for translation. At the end of form there is the submit button.
I want to activate/deactivate automatically the submit button when conditions are met:
- When I leave one input (jQuery "blur"): check if this one and all other inputs are empty or not.
If I use .each() function followed by $(this) I get all values of form but if $(this) object is called after $(this).on('blur',...) it is no longer focuses on inputs form.
How can I get a list of inputs value after leaving one of them ?
$('form input').each(function(){
var eachinput = $(this);
// Well return list of form inputs ->
console.log('name='+ $(this).attr('name')+ ' value='+ $(this).val());
$(this).on('blur',function(){
//Return the last input filled instead of all form inputs ->
console.log('name='+ eachinput.attr('name')+ ' value='+ eachinput.val());
if($('input').val().length == 0){ // If All empty (and flag not selected)
$('#translation_button').prop( "disabled", true );
}else{ // If one of input filled (and flag is selected)
$('#translation_button').prop( "disabled", false );
}
});
});
I have tried .get(), but it doesn't work with .val() and .attr().