我使用jcryption对form.It进行加密,如果我在表单中使用提交按钮,效果会很好。相反,如果我使用button并手动提交表单,我的jcryption方法不会被调用。
below is my code
<html>
<head>
<script type="text/javascript">
$(document).ready(function() {
$("#login").bind('click', function(){
document.authenticatorform.username.value=$("#username").val();
document.authenticatorform.password.value=$("#password").val();
alert('outer hello');
$("#authenticatorform").jCryption({
getKeysURL:"<%=request.getContextPath()%>/keypairrequest",
beforeEncryption:function() {
alert('inner hello');
document.authenticatorform.submit()
return true; },
encryptionFinished:function(encryptedString, objectLength) {return true;}
});
});
});
</script>
<body>
<form:form method="post" action="login.htm" name="authenticatorform" id="authenticatorform">
<input type="hidden" name="username"/>
<input type="hidden" name="password"/>
</form:form>
<input type="button" id="login"/>
</body>
</html>在代码中,只有外部警报是打印的。
除了提交按钮之外,还可以调用jcryption吗?
非常感谢您的帮助!
发布于 2017-07-29 12:36:58
尝试在单击函数上使用,而不是使用绑定
Try this:
$("#login").on('click', function(){
//your codes goes here
}https://stackoverflow.com/questions/45384939
复制相似问题