方法1:使用form onsubmit标签 return XXX()方法

<!--onsubmit-->
<form id="formid" name="myform" method='post' onsubmit="return checkUser();">
<table border="0">
<tr>
<td width="60" height="40" align="right">用户名&nbsp;</td>
<td><input type="text" value="" class="text2" name="username" id="userid" /></td>
</tr>
<tr>
<td width="60" height="40" align="right">密&nbsp;&nbsp;码&nbsp;</td>
<td><input type="password" value="" class="text2" name="userpass" id="userpassid" /></td>
</tr>
<tr>
<td width="60" height="40" align="right">&nbsp;</td>
<td>
<div class="c4">
<input type="submit" value="登录" class="btn2"/>
</div>
</td>
</table>
</form>
<script>
function checkUser() {
var result = document.getElementById("userid").value;
var password = document.getElementById("userpassid").value;
if (result == "") {
alert("用户名不能为空");
return false;
}
if (password == "") {
alert("密码不能为空");
return false;
}
}
debugger;
alert('Your data is correct.');
</script>

方法2:input onclick标签

<form id="formid" name="myform" method='post'>
<table border="0">
<tr>
<td width="60" height="40" align="right">用户名&nbsp;</td>
<td><input type="text" value="" class="text2" name="username" id="userid" /></td>
</tr>
<tr>
<td width="60" height="40" align="right">密&nbsp;&nbsp;码&nbsp;</td>
<td><input type="password" value="" class="text2" name="userpass" id="userpassid" /></td>
</tr>
<tr>
<td width="60" height="40" align="right">&nbsp;</td>
<td>
<div class="c4">
<!--onclick-->
<input type="submit" value="登录" class="btn2" onclick="checkUser();"/>
</div>
</td>
</table>
</form>

Form submit的更多相关文章

  1. form.submit() not a function的元凶

    今天晚上学习jquery form plugin时,在明白了该插件的用法时, (1)该插件是将form的HTTP请求 改为AJax请求. (2)支持像jQuery.ajax(options)一样 的o ...

  2. form submit时将__VIEWSTATE和__VIEWSTATEGENERATOR一起post到另外的页面,出现验证视图状态 MAC 失败。

    错误信息: 验证视图状态 MAC 失败.如果此应用程序由网络场或群集承载,请确保 配置指定了相同的 validationKey 和验证算法.不能在群集中使用 AutoGenerate. 原因分析: F ...

  3. 文件上传时jquery.form.js中提示form.submit SCRIPT5: 拒绝访问

    利用其它控件触发file的click事件来选择文件后,使用jquery.form.js中的submit方法提交时IE报错:form.submit SCRIPT5: 拒绝访问,其它浏览器正常, < ...

  4. easyui form submit 不提交

    http://bbs.csdn.net/topics/390811964 function saveProduct() {             //$('#fm').form('submit',  ...

  5. js提交表单错误:document.form.submit() is not a function

    今天在写JS时,遇上这么个错误:"document.form.submit() is not a function",经过一番搜索,最终找到了修复方法. 这个错误一般是由于表单&l ...

  6. form submit提交

    form内控件参数自动添加到url后,而自定义的url参数则不能添加到url后 $('#fm').form('submit', { url: 'Data/Diary.ashx?dt=' + new D ...

  7. [ext]form.submit()相关说明

    form.submit({    url:"../addOrUpdatePack.shtml",method:'POST',success:function(f,action) { ...

  8. AJAX Form Submit Framework 原生js post json

    https://developer.mozilla.org/en-US/docs/Web/API/XMLHttpRequest/Using_XMLHttpRequest <!doctype ht ...

  9. <input type = "submit"> 提交方式和用js的form.submit()有什么区别?

    假设: A表单内有<input type="submit">,通过点击这个input来提交表单 B表单内没有<input type="submit&qu ...

  10. form.submit 方法 并不会触发 form.onsubmit 事件

    做表单的时候发现一个奇怪的地方,总结下: form.submit 方法 并不会触发 form.onsubmit 事件,看代码: <body> <div class="con ...

随机推荐

  1. Cisco IOS images

    Cisco IOS images for Dynamips - GNS3http://docs.gns3.com/1-kBrTplBltp9P3P-AigoMzlDO-ISyL1h3bYpOl5Q8m ...

  2. Java中的equals比较,小坑一个

    最近工作中,经常需要比较2个对象的值.有个问题经常遇到,就是下面的2种情况. public static void main(String[] args) { Integer a =11; Objec ...

  3. linux网络编程学习笔记之二 -----错误异常处理和各种碎碎(更新中)

    errno 在unix系统中对大部分系统调用非正常返回时,通常返回值为-1.并设置全局变量errno(errno.h),如socket(), bind(), accept(), listen(). e ...

  4. iOS 日志自动上报

       您好,欢迎使用腾讯Bugly!腾讯Bugly是腾讯公司为移动开发者开放的服务之一. 针对移动应用,腾讯Bugly提供了专业的Crash(崩溃).Android ANR(application n ...

  5. 学习鸟哥的Linux私房菜笔记(13)——用户管理

    一.检查用户身份 用户可以使用下列指令了解用户身份 who :查询当前在线的用户 groups :查询用户所属组 id :显示当前用户信息 finger :查询用户信息 二.添加用户 用指令添加命令 ...

  6. 【26.09%】【codeforces 579C】A Problem about Polyline

    time limit per test1 second memory limit per test256 megabytes inputstandard input outputstandard ou ...

  7. 【17.07%】【codeforces 583D】Once Again...

    time limit per test1 second memory limit per test256 megabytes inputstandard input outputstandard ou ...

  8. TDM-GCC是从mingw-w64项目patch而来,全部使用静态链接,对线程不需要额外的DLL,默认使用SJLJ异常(真是好东西)

    Windows版GCC之TDM-GCC 4.5.2 平时写 C/C++ 小程序的时候,不喜欢开VS,太庞大了,还要建项目.对于小程序,一个可以进行单文件编译的 IDE 是我的首选,我用的是 C-Fre ...

  9. vue 百度地图

    <template lang="pug"> #select-area-in-map-content #show-message-info el-popover(plac ...

  10. HBase 查找版本

    直接使用hbase shell命令进入shell时间会告诉版本: 进shell后.关键在version命令.能够查看版本: # hbase shell HBase Shell; enter 'help ...