form表单的两种提交方式,submit和button的用法
来源:互联网 发布:杀破狼js mp3下载 编辑:程序博客网 时间:2024/05/20 17:25
方法一:
在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的用法
- RANSAC、ICP、图优化g2o学习笔记
- 概率3
- CS231n课程笔记翻译:神经网络笔记3
- 生物信息实用语言
- 使用Cheat Engine实现单机游戏作弊
- form表单的两种提交方式,submit和button的用法
- 进程、线程、进程间通信等概念
- Android进阶之路 - BroadcaseReceiver(自定义广播、有序广播、无序广播、广播拦截、动态注册、静态注册)的详细使用方式
- deskclock,background颜色会变化
- sift算法译文
- 使用 Homebrew 安装 Git
- PS cs6快速制作一个简易gif图
- 【Unity 3D学习】获取鼠标点击所对应的GameObject
- 易筋经十二式