我有这个 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....否则回显“错误验证””,但我对 jquery 和 javascript 不太了解。..有可能让这两件事一起工作吗?
这里是 jquery 验证的 API:http://posabsolute.github.io/jQuery-Validation-Engine
最佳答案
您可以使用 jquery 验证引擎
和自定义验证来验证您的表单
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();
}
}
关于javascript - Jquery 验证引擎 onclick,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17086804/