2

我有这个 jquery 插件 Jquery ValidationEngine 它是由这个触发的:

    <script>
        jQuery(document).ready(function(){
            // binds form submission and fields to the validation engine
            jQuery("#editar").validationEngine('attach');
        });
</script>

它工作正常,但在提交按钮上我有这个:

<input type="submit" value="SUBMIT" onclick="formhash(this.form, this.form.password);"  id="BotaoEntrar"/></td>

该 onclick 通过 javascript 文件 (THIS) 发送密码:

    function formhash(form, password) {
   // Create a new element input, this will be out hashed password field.
   var p = document.getElementById("p");
   // Add the new element to our form.
   form.appendChild(p);
   p.name = "p";
   p.type = "hidden"
   p.value = hex_sha512(password.value);
   // Make sure the plaintext password doesn't get sent.
   password.value = "";
   // Finally submit the form.
   form.submit();
}

所以这里的这个东西“削减”了验证jquery(如果我删除onclick它工作正常,但加密密码不起作用)但我希望这两件事一起工作..

类似“如果验证正确 - > formhash.... else echo”错误验证“”之类的东西,但我对 jquery 和 javascript 了解不多。这两个东西可以一起工作吗?

这是 jquery 验证的 API:http: //posabsolute.github.io/jQuery-Validation-Engine

4

1 回答 1

0

您可以jquery validation engine使用自定义验证来验证您的表单

jQuery(document).ready(function(){

 jQuery("#editar").validationEngine();
 });


function formhash(form, password) {

if(jQuery("#editar").validationEngine('validate')){
//    first validates with jquery  validationEngine if retuns true then your validation takes place
// Create a new element input, this will be out hashed password field.
var p = document.getElementById("p");
// Add the new element to our form.
form.appendChild(p);
p.name = "p";
p.type = "hidden"
p.value = hex_sha512(password.value);
// Make sure the plaintext password doesn't get sent.
password.value = "";
// Finally submit the form.
 form.submit();


 }
}
于 2013-06-13T12:47:06.420 回答