$("#sign-up-btn").click(function(){ var isSubmit = true; var inputs = document.getElementsByTagName("input"); var checkInfo = null; for(var i= 0, len=inputs.length; i<len; i++){ $(inputs[i]).trigger('blur'); checkInfo = inputs[i].getAttribute("checkinfo"); if(checkInfo){ isSubmit = false; return false; } } if(isSubmit){ var zc = sy.getCookie("regZendCode"); if(zc != null){ $zendcode = zc; } $.post(sy.contextPath+"/base/client!doNotNeedSessionAndSecurity_webclientregister.sy",sy.serializeObject($("#sign-up-post")),function(data){ if(data.success){ $('#reg-in-warning').hide(); sy.cookie("IBankUserName",data.msg); location.replace(sy.contextPath + '/loginWebClient/client.jsp'); }else{ $('#reg-in-warning').show(); } }, 'json'); } });
$(document).keydown(function(e){ if (!e){ e = window.event; } if ((e.keyCode || e.which) == 13) { $("#sign-up-btn").click(); } })
jQuery中的keydown()可以实现按键功能,取按键的ASCII码来对应按键。