简体   繁体   中英

jQuery Validation Engine not working

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>`

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

$(document).ready(function(){
    $("#formID").validationEngine(); 
});

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM