validate
validate copied to clipboard
'Form incomplete' if textarea is last input
Spotted this bug where textarea causes form to fail as Incomplete if it is the last :input element. Looks like adding a colon to 'input' fixes it, as so... [in validate.js]
form: function(oForm, fnSuccess, fnFailure){
//console.log('form');
oForm.find(':input').each(function(){
if(!$(this).hasClass('vsuccess') && !$(this).hasClass('vwarning') && !$(this).hasClass('vincomplete')){
validate.input($(this), function(oInput){
validate.form(oForm, fnSuccess, fnFailure);
});
return false;
} else if(oForm.find(':input:last').attr('id') == $(this).attr('id')){ //check if input is the last input ---------------------> prefix colon so = (':input:last') NOT ('input:last')
if(validate.isFormSuccess(oForm) === true){ //if every input has success classes
fnSuccess(oForm); //submit form
} else {
validate.setIncomplete(oForm); //sets all warning classes to incomplete instead to make it more bold
fnFailure();
}
return false;
}
return true; //skip to next input if it has a class already and is not the last input
});
}, ...
UPDATE: the above causes the validation to break if a chosen Select is used. So for now, I'm just using a hidden input as my last input element whenever I need to have a textarea element as the final visible form element. Any thoughts? Thanks!
Yes actually I have a fix for that, I will update later today. The update rounds up all the elements by explicitly selecting 'input, select, textarea' then filters the :last element of those, and it works. I had the same problem. Updating just now.