bootstrap表单怎么提交信息

发布时间:2022-05-19 发布网站:脚本宝典
脚本宝典收集整理的这篇文章主要介绍了bootstrap表单怎么提交信息脚本宝典觉得挺不错的,现在分享给大家,也给大家做个参考。

bootstrap表单怎么提交信息

当输入用户名和密码为空的时候,需要判断。这时候就用到了校验用户名和密码,这个需要在jsp的前端页面写;有两种方法,一种是用submIT提交。一种是用button提交。

方法一:

在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 = &#39;post'  action = 'user_login_submit.action' onsubmit = "return checkUser();" >
            <table width="100%" border="0">
              <tr>
                <td width="60" height="40" align="right">用户名&amp;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"  />

方法二:

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();" />

推荐:bootstrap入门教程

以上就是bootstrap表单怎么提交信息的详细内容,更多请关注脚本宝典其它相关文章

脚本宝典总结

以上是脚本宝典为你收集整理的bootstrap表单怎么提交信息全部内容,希望文章能够帮你解决bootstrap表单怎么提交信息所遇到的问题。

如果觉得脚本宝典网站内容还不错,欢迎将脚本宝典推荐好友。

本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。
标签: