Question

where can i put the confirm popup for the mootools validation tool

confirm script:

if (confirm('Have you reviewed the information?')) { }

mootools script:

<script type="text/javascript">

    window.addEvent('domready', function(){

        // The elements used.
        var myForm = document.id('leadForm'),
            myResult = document.id('myResult');

        // Labels over the inputs.
        myForm.getElements('[type=text], textarea, select' ).each(function(el){
            new OverText(el);
        });

        // Validation.
        new Form.Validator.Inline(myForm);

        // Ajax (integrates with the validator).
        new Form.Request(leadForm, myResult, {
            requestOptions: {
                'spinnerTarget': myForm
            },
            extraData: { // This is just to make this example work.
                'html': 'Form sent.'
            }
        });

    });
    </script>

where can i put the confirmation so that before sending the form a popup will alert the user for a yes an no answer?

Was it helpful?

Solution

Try this:

$('myForm').addEvent('submit', function (event) {
    event.preventDefault();
    if (confirm('Have you reviewed the information?')) {            
        //code if true
    }else{ return false;}
});

This will add a event listener so that when form is submitting he will call the function inside it.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top