日期:2014-05-16 浏览次数:20426 次
js文件jQuery配置
jQuery(document).ready( function() {
??? jQuery("#loginForm").submit( function() {
??? ??? var canSubmit = new Boolean(true);
??? ???
??? ??? if (jQuery("#email").val() == "") {
??? ??? ??? jQuery("#emailErrorLogin").text(jQuery.l10n.__("Your login name is not meet E-mail format") );
??? ??? ??? canSubmit = false;
??? ??? }else
??? ??? ??? jQuery("#emailErrorLogin").empty();
??? ??? if (jQuery("#password").val() == "") {
??? ??? ??? jQuery("#passwordErrorLogin").text(jQuery.l10n.__("Password is a requested field!") );
??? ??? ??? canSubmit = false;
??? ??? } else
??? ??? ??? jQuery("#passwordErrorLogin").empty();
??????? //判断邮箱格式
??????? var emailReg = /^\w+([-+.]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*$/;
??? ??? if (jQuery("#email").val() == "") {
??? ??? ??? jQuery("#emailError").text(jQuery.l10n.__("E-Mail is a requested field!") );
??? ??? ??? canSubmit = false;
??? ??? } else if (!emailReg.test(jQuery("#email").val())) {
??? ??? ??? jQuery("#emailError").text(jQuery.l10n.__("Your E-Mail format is incorrect!") );
??? ??? ??? canSubmit = false;
??? ??? } else
??? ??? ??? jQuery("#emailError").empty();
??? ??? ??? return canSubmit;
??? ??? });
});
?
jsp页面应用
<form id="loginForm" action="${pageContext.request.contextPath}/user/login" method="post">
??? <table class="formtable" align="center">
??? ??? <tr>
??? ??? ??? <th><fmt:message key="user.email"/></th>
??? ??? ??? <td><input id="email" name="email"/></td>
??? ??? ??? <td id="emailErrorLogin"></td>
??? ??? </tr>
......