validate icon indicating copy to clipboard operation
validate copied to clipboard

'Form incomplete' if textarea is last input

Open NeilJS opened this issue 11 years ago • 2 comments

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
        });
    }, ...

NeilJS avatar Feb 19 '14 16:02 NeilJS

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!

NeilJS avatar Feb 21 '14 14:02 NeilJS

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.

mbignold avatar Feb 21 '14 14:02 mbignold