2

Trying to use the jQuery validation engine for 1 text field. For some reason It's not doing anything. I don't any errors to work off. If anyone see's something missing or out of place, I'd appreciate it.`

<!DOCTYPE html>
<html>
<head>

<meta charset="UTF-8" />

 <script src='jquery-1.11.0.min.js'></script>
<script src="jQuery-Validation-Engine-master/js/languages/jquery.validationEngine-en.js" type="text/javascript" charset="utf-8"></script>
<script src="jQuery-Validation-Engine-master/js/jquery.validationEngine.js" type="text/javascript" charset="utf-8"></script>

<link rel="stylesheet" href="jQuery-Validation-Engine-master/css/validationEngine.jquery.css" type="text/css"/> 

</head> 
<body>

<form id="formID" name="myForm" method="post" action="submit.action">     

     <input class="validate[required]" type="text" id="agree" name="agree"/>         
     <button type="button" value="Save" id="Save" onclick="clicked();">Submit Survey</button>

</form>

<script type="text/javascript">

  function clicked() {
        if (confirm('Are you sure you want to submit?')) {
            $("#form.id").validationEngine();               

        } else {
            return false;
        }
    }

 </script>  
</body>
</html>`
1
  • if someone is able to recreate my code on their machine that might be helpful as I'm wondering if there is something else wrong other than syntax. Commented Nov 15, 2013 at 15:02

2 Answers 2

4

You should initialize validationEngine like so and not in a onclick function:

$(document).ready(function(){
    $("#formID").validationEngine(); 
});
Sign up to request clarification or add additional context in comments.

3 Comments

are you sure the validation engine script is being loaded? Are there any errors in the console window of your browser? You can go there by pressing F12 in your browser
Try changing your button to <input type="submit" value="save" />
The button wont submit the form, validation engine will validate the form on submit. That's why the button didn't work and the input did.
3

Your selector is wrong

change:

$("#form.id").validationEngine();  

$("#form.id") --> refers to element with id form and class id

to:

$("#formID").validationEngine();  

Read # id selector

2 Comments

makes sense but still nothing.
this works as well, just had to use type=submit as Jop mentioned above.

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.