教程集 www.jiaochengji.com
教程集 >  jQuery  >  jquery 教程  >  正文 JQuery验证jsp页面属性是否为空(实例代码)

JQuery验证jsp页面属性是否为空(实例代码)

发布时间:2014-05-03   编辑:jiaochengji.com
JQuery验证jsp页面属性是否为空的实例代码。需要的朋友可以过来参考下,希望对大家有所帮助

说明:验证是否为空的前提首先要保证是在提交form之前验证的,如果验证结果有为空的项那么限制表单不能提交,并且提示验证错误信息,验证页面属性都不为空的情况下表单正常提交,这部分属于JS部分的东西,与后台业务逻辑层和控制层基本没有任何关系。

限制提交的方法可以是在form标签里限制,也可以是在submit按钮上添加onclick事件限制:

<form action=".." method="post" onsubmit="return check();">
<input type="submit" value="提交" onclick="return check()" >

案例:

复制代码 代码如下:

<form action="./login.action" method="post" onsubmit="return check();">
<table>
<tr>
<td width="451"> </td>
<td width="378">

<table >
<tr>
<td width="60"> </td>
<td>
<font color="#000000">用户名:</font>
</td>
<td align="left"> <input name="userInfo.userName" id="userName" type="text">
<span id="checkUserName"></span>
</td>
<tr> <td> </td>
<td align="right" nowrap>
<font color="#000000">密 码:</font>
</td>
<td align="left">
<input name="userInfo.password" id="password" type="password">
<span id="checkPassword"></span>
</td>
</tr>
<tr>
<td colspan="4" align="center" nowrap>
<input type="submit" id="btnLog" value=" 登 录 " >
   <input type="reset" value=" 重 置 ">
</td>
</tr>
</table>
</form>

您可能感兴趣的文章:
JQuery验证jsp页面属性是否为空(实例代码)
JSP常见问题
jValidate 基于jQuery的表单验证插件
jquery ajax 登录验证实现代码
jquery ajax 登录验证的代码
基于jQuery的前端数据通用验证库
建立JSP操作以提高数据库访问的效率
servlet与jsp基础教程(11)-JSP及语法概要
servlet与jsp基础教程(12)-脚本元素、指令和预定义变量
jquery插件制作 表单验证实现代码

关键词: JQuery  验证   
[关闭]
~ ~