start form validation only on submit

my form is starting the validation (with this plugin) the minute user start typing. for example if i have password input and retype password input, when typing the first character on password it immediately show ‘password mismatch’ but the user didn’t have the chance to type the retype password.

how do i disable the validation on typing and only show errors when the user click on submit? are there any options?

BUT, username with remote check i do want it to show the error when the input if out of focus

$('#frm_user_details').formValidation('validate');

$('#frm_user_details').formValidation({
            framework: 'bootstrap',
            fields: {
                register_first_name: {
                    validators: {
                        notEmpty: {
                            message: 'Please enter your first name'
                        }
                    }
                },
                register_last_name: {
                    validators: {
                        notEmpty: {
                            message: 'Please enter your last name'
                        }
                    }
                },
                username: {
                    validators: {
                        notEmpty: {
                            message: 'Please enter a username.'
                        },
                        remote: {
                            type: 'POST',
                            url: '/core/services/validator.php',
                            message: 'That username is already taken.',
                            delay: 500
                        }
                    }
                },
                register_password: {
                    validators: {
                        notEmpty: {
                            message: 'The password is required and cannot be empty'
                        },
                        identical: {
                            field: 'register_password_retyped',
                            message: 'The password and its confirm must be the same'
                        }
                    }
                },
                register_password_retyped: {
                    validators: {
                        notEmpty: {
                            message: 'The confirm password is required and cannot be empty'
                        },
                        identical: {
                            field: 'register_password',
                            message: 'The password and its confirm must be the same'
                        }
                    }
                },

            },
            onError: function(e) {
                e.preventDefault();
                $('#create_account').removeClass('button-disabled');
            },
            onSuccess: function(e) {
                e.preventDefault();
                $('#create_account').addClass('button-disabled');
                    THIS.services.submitHandler();
                }
            }
        });


Source: jquery

Leave a Reply