2

I'm using the ajax form plugin and that is the way how I handle my forms. Now I decided to add a beautiful plugin - validationengine. But I don't know how to integrate it. The code I have:

        $("#addCompanyForm").validationEngine({scroll:false});
        $("#addCompanyForm").ajaxForm({
            beforeSubmit: function() {
                valid = $("#addCompanyForm").validationEngine('validate');
                if (valid == false) return false;
                //some actions like blocking interface (show loader) etc
            },
            url: myURL,
            success: function() {
                //some actions like unblocking interface etc
            }
        });

Well, I have an inline validation and when I push the submit button it submits data and after that again validate the inline input (and probably all others too). What I want to have: when I blur inputs I need to have validation (including ajax inline) and when I submit I need validation.

And also I don't clearly understand the scheme. For example I have a form with lots of inputs. When I push the submit button the validationengine have to check the inputs and after that I send data to my php script, which have to check them again? (In case we're dealing with hack attempt). And if data is not valid for example we can just use something like

Thanks in advance, I would really appreciate any help

1
  • Looking for help on this one too. Since it has passed a while since the question, did you managed to find an awnser to it? Commented Aug 9, 2012 at 15:38

1 Answer 1

2

After looking for a while for a solution for my exact problem, found it.

<script>
    $(function() { 
        var options = { 
            target:        '#save',
            dataType:      'json',
            beforeSubmit:  showRequest,
            success:       showResponse
        }; 
        $('#form').validationEngine({scroll:false});
        $('#form').ajaxForm(options);

    });

    function showRequest(formData, jqForm, options) { 
        var valid = $("#form").validationEngine('validate');
        if (valid == true) {
            $("#save").fadeIn().html('<p class="message loading">Saving...</p>');
            return true;
        }else{
            return false;
        }
    } 

    function showResponse(data, responseText, statusText)  { 
        $("#save").fadeOut().html('<p class="message success">Saved.</p>');
    } 
</script>
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.