form表单的两种提交方式,submit和button的用法
来源:互联网 发布:淘宝 退款 空包犯法嘛 编辑:程序博客网 时间:2024/05/20 18:45
方法一:
在jsp的前端页面的头部插入一个js方法:
function checkUser(){
var result = document.getElementById("userid").value;
var password = document.getElementById("userpassid").value;
if(result == "" ){
alert("用户名不能为空");
return false;
}
if(password == "" ){
alert("密码不能为空");
return false;
}else{
return true;
}
}
在form表单里写成这样:
<form id="formid" name= "myform" method = 'post' action = 'user_login_submit.action'onsubmit = "return checkUser();" >
<table width="100%" border="0">
<tr>
<td width="60" height="40" align="right">用户名 </td>
<td><input type="text" value="" class="text2" name = "username" id = "userid"/></td>
</tr>
<tr>
<td width="60" height="40" align="right">密 码 </td>
<td><input type="password" value="" class="text2" name = "userpass" id = "userpassid"/></td>
</tr>
<tr>
<td width="60" height="40" align="right"> </td>
<td><div class="c4">
<input type="submit" value="" class="btn2" />
方法二:
function checkUser(){
var result = document.getElementById("userid").value;
var password = document.getElementById("passid").value;
if(result == "" ){
alert("用户名不能为空");
return false;
}
if(password == "" ){
alert("密码不能为空");
return false;
}
document.getElementById("formid").submit();
}
form表格的写法,需要写id
<form id="formid" method = 'post' action = 'user_login_submit.action' >
button按钮的写法如下:
<input type="button" value="" class="btn2" onclick = "checkUser();" />
http://blog.csdn.net/honey_claire/article/details/7658490
- form表单的两种提交方式,submit和button的用法
- form表单的两种提交方式,submit和button的用法
- form表单的两种提交方式,submit和button的用法
- honey-----form表单的两种提交方式,submit和button的用法
- form表单的两种提交方式,submit和button的用法
- form表单的两种提交方式,submit和button的用法
- form表单的两种提交方式,submit和button的用法
- form表单的两种提交方式,submit和button的用法
- form表单的两种提交方式,submit和button的用法
- form表单的两种提交方式,submit和button的用法
- form表单的两种提交方式,submit和button的用法
- form表单的两种提交方式,submit和button的用法
- form表单的两种提交方式,submit和button的用法
- form表单的两种提交方式,submit和button的用法
- form表单的两种提交方式,submit和button的用法
- form表单的两种提交方式,submit和button的用法
- 触发form表单的两种提交方式,submit和button的用法
- form表单的两种提交方式,submit和button的用法
- B2C商城(非平台)需求设计
- Android View框架总结(七)View事件分发机制
- MyEclipse/Eclipse常用小功能--持续更新...
- Matlab之GPU加速方法
- picoCTF2013 wirteup (一)
- form表单的两种提交方式,submit和button的用法
- <context:component-scan>使用说明
- 冒泡排序
- Codeforces Round #317 [AimFund Thanks-Round] (Div. 2) D. Minimization
- 配置vim作为python、php开发环境
- NOIP2015 提高组 day1 神奇的幻方
- Switch的识别
- Android View框架总结(八)ViewGroup事件分发机制
- Servlet的几个方法介绍(init() 、service()、doGet() 、doPost()、destroy()、getServletConfig()、getServletInfo())