<html>
<head>
<meta charset="UTF-8">
<title>Insert title here</title>
</head>
<body>
<form action="https://www.baidu.com/" method="post" id="loginForm">
姓名:<input type="text" name="username" id="username">
密碼:<input type="text" name="pwd" id="pwd">
<button id="submitbut" style="display: block;">提交</button>
</form>
</body>
<script src="ajax運行基礎/js/jquery-1.9.1.min.js" type="text/javascript" charset="utf-8"></script>
<script src="layer/layer-v3.1.1/layer/layer.js" type="text/javascript" charset="utf-8"></script>
<script type="text/javascript">
$("#submitbut").click(function(){
var name = $.trim($("#username").val());
var pwd = $.trim($("#pwd").val());
if(name == ""){
layer.tips('姓名不能爲空', '#username', {
tips: 3
});
return false;
}
if(pwd == ""){
layer.tips('密碼不能爲空', '#pwd', {
tips: 3
});
return false;
}
$("#loginForm").submit();
});
</script>
</html>javascript