form表单的两种提交方式,submit和button的用法
来源:互联网 发布:js请求servlet 编辑:程序博客网 时间:2024/05/20 16:12
方法一:
在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();" />
- 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的用法
- 最新极光推送在ios模拟器上无法运行
- javascript中对原型的理解
- angularjs 与 ueditor 使用的时候 setContent 报错
- c++ explicit
- JAVA中调用C语言接口
- form表单的两种提交方式,submit和button的用法
- 挑战密室,第八届河南省省赛,郑大OJ10406
- Android 通过JitPack让自己开源库可以被别人引用
- Utf8和Unicode转换问题 C语言 千字文问题
- Maven常用命令
- Logger日志级别说明及设置方法、说明
- 深度学习 16. 反向传递算法最简单的理解与提高,BP算法,Backpropagation, 自己的心得。
- PHP判断是不是https协议
- vitrualbox安装后centos后的网络配置(host-only)