MyException - 我的异常网
当前位置:我的异常网» Java Web开发 » 登录时,当用户名或密码一项为空时,怎么弹出提示框

登录时,当用户名或密码一项为空时,怎么弹出提示框提示用户,两项都添加后再进行提交操作

www.MyException.Cn  网友分享于:2013-12-16  浏览:845次
登录时,当用户名或密码一项为空时,如何弹出提示框提示用户,两项都添加后再进行提交操作?
一下是代码,应如何添加?

<%@   taglib   uri= "/WEB-INF/struts-tiles.tld "   prefix= "tiles "   %>
<%@   taglib   uri= "/WEB-INF/struts-nested.tld "   prefix= "nested "   %>
<%@   taglib   uri= "/WEB-INF/struts-logic.tld "   prefix= "logic "   %>
<%@   taglib   uri= "/WEB-INF/struts-template.tld "   prefix= "template "   %>
<%@   taglib   uri= "/WEB-INF/struts-bean.tld "   prefix= "bean "   %>
<%@   taglib   uri= "/WEB-INF/struts-html.tld "   prefix= "html "   %>
<%@   page   contentType= "text/html;   charset=GBK "   %>
<html:html   xhtml= "true "   locale= "true ">
<head>
<title>
login.jsp
</title>
<html:base/>
</head>
<body>
<h1> h1>
<p>
<html:form   action= "/loginAction.do "   method= "POST ">

<html:text   property= "username "/>
<br>
<html:password   property= "password "/>
<br>

<html:submit   property= "submit "   value= "Submit "/> <br>
<html:reset   value   = "Reset "/>
</html:form>
</body>
</html:html>

------解决方案--------------------
<%@ taglib uri= "/WEB-INF/struts-tiles.tld " prefix= "tiles " %>
<%@ taglib uri= "/WEB-INF/struts-nested.tld " prefix= "nested " %>
<%@ taglib uri= "/WEB-INF/struts-logic.tld " prefix= "logic " %>
<%@ taglib uri= "/WEB-INF/struts-template.tld " prefix= "template " %>
<%@ taglib uri= "/WEB-INF/struts-bean.tld " prefix= "bean " %>
<%@ taglib uri= "/WEB-INF/struts-html.tld " prefix= "html " %>
<%@ page contentType= "text/html; charset=GBK " %>
<html:html xhtml= "true " locale= "true ">
<head>
<title>
login.jsp
</title>
<html:base/>
</head>
<body>
<script type= "text/javascript "> -------------------------------增加的
function submit1()
{


if(za.aa.value== " "){
alert( "请输入发送信息内容 ");
za.aa.focus();
return false;
}
}
</script>
<h1> </h1>
<p>
<html:form action= "/loginAction.do " name= "za " method= "POST ">

<html:text name= "aa " property= "username "/>
<br>
<html:password property= "password "/>
<br>

<html:submit property= "submit " onclick= "return submit1() " value= "Submit "/> <br> ----增加的submit1() "

<html:reset value = "Reset "/>
</html:form>
</body>
</html:html>

------解决方案--------------------
function check() {
  var usernameText = document.getElementsByName( "username ")[0];
  var passwordText = document.getElementsByName( "password ")[0];

文章评论

软件开发程序错误异常ExceptionCopyright © 2009-2015 MyException 版权所有