2

My question i have the above form in my page. i want to validate the form using jquery validation engine.Can you pls tell me how to validate it and what r the files to include. now, i have included the jquery validation engine in my head. i just want to know how to trigger the validation engine and show the error message onblur of the text fields.. many thanks in advance.please find my code below:

<script src="../js/jquery-1.6.min.js" type="text/javascript"></script>
<script src="scripts/jquery.validationEngine-en.js" type="text/javascript" charset="utf-8"></script>
<script src="scripts/jquery.validationEngine.js" type="text/javascript" charset="utf-8"></script>
<script type="text/javascript">

    jQuery(document).ready(function(){
        // binds form submission and fields to the validation engine
        $('#myForm').validationEngine('validate');
    });


</script>
<form class="container" id="myForm" method="post" action="">
    <div>
        <span>Field is required : </span>
        <label for="Firstname">Firstname</label>
        <input type="text" class="validate[required] text-input" id="name" name="Firstname"/>
    </div>
    <div>
        <span>Field is required : </span>
        <label for="name">middlename</label>
        <input type="text" id="name" name="middlename" class="validate[required] text-input"/>
    </div>
    <div>
        <span>Field is required : </span>
        <label for="name">lastname</label>
        <input type="text" id="name" name="lastname" class="validate[required] text-input"/>
    </div>
</form>
3
  • Hi, My question i have the above form in my page. i want to validate the form using jauery validation engine.Can you pls tell me how to validate it and what r the files to include. now, i have included the jquery validation engine in my head. i just want to know how to trigger the validation engine and show the error message onblur of the text fields.. many thanks in advance Commented Dec 25, 2011 at 9:06
  • 1
    Probably related to this question. It got downvotes for a reason, you know. Commented Dec 25, 2011 at 9:15
  • Do not ask the same question repeatedly. Commented Dec 26, 2011 at 14:47

4 Answers 4

10

Change your jquery code to this :

<script type="text/javascript">

   jQuery(document).ready(function(){
       // binds form submission and fields to the validation engine
       $('#myForm').validationEngine();
   });

</script>

Then add some classes to your form field , for example :

it is an input text and it is required :

<input type='text' class="validate[required] text-input">

or this one is an input text for just emails :

<input type='text' class="validate[required,custom[email]] text-input">

put a button and on its Click event call a javascript function like this :

function myValidation()
{

    if ($('#myForm').validationEngine('validate'))   
    { 
        //do somthing here beacause your form is valid
    }
}

For more help comment me

Sign up to request clarification or add additional context in comments.

Comments

7

Refer this jQuery.validationEngine to know how to use Validation Engine.

For writing Custom rule, refer this existing question jQuery Validate Plugin - How to create a simple custom rule?

1 Comment

Thanks siva.. that article was helpful :)
3

all thing go right and you do that correct ,you can just call this method to validate all the field of your form

$('#myForm').validationEngine('validate');

this will return true if all field of your form validate right , else return false

Comments

1

Follow this:

Download jquery validation engine plugin from here. And extract it.

Inside the folder you can find these two files.

jquery.validationEngine-en.js 
jquery.validationEngine.js

Copy & Paste in assets->scripts-> of your working project.

Then change the src path like below.

<script src="assets/scripts/jquery.validationEngine-en.js" type="text/javascript" charset="utf-8"></script>

<script src="assets/scripts/jquery.validationEngine.js" type="text/javascript" charset="utf-8"></script>

In Your Coding do the following:

<script>
    $(document).ready(function(){
        $("#id of ur form").validationEngine();
    });
</script>

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.