日期:2014-05-16 浏览次数:20488 次
$('#confirm_button').click(function(e){
var $username = $('input:eq(0)').val();
var $password = $('input:eq(1)').val();
if($username=="" || $password==""){
e.preventDefault();
alert('内容为空无法提交!');
}
});
<form action="" method = "post" name = "form">
<table>
<tr>
<td> 账号: </td>
<td><input type="text" name ="username" size = "16" maxlength = "30" id='user' value='请输入账号'></td>
</tr>
<tr>
<td> 密码: </td>
<td><input type="text" name ="password" size = "16" maxlength = "30" value='请输入密码'></td>
</tr>
<tr>
<td> <input type="submit" value="确定" class='button' id='confirm_button'></td>
<td> <input type="reset" value = "重置" class = 'button' id = 'reset_button'></td>
</tr>
</table>
</form>
<script type="text/javascript" src="http://code.jquery.com/jquery-latest.js"></script>
<form action="" method = "post" name = "form" id='form1'>
<table>
<tr>
<td> 账号: </td>
<td><input type="text" name ="username" size = "16" maxlength = "30" id='user' value=''></td>
</tr>
<tr>
<td> 密码: </td>
<td><input type="text" name ="password" size = "16" maxlength = "30" value=''></td>
</tr>
<tr>
<td> <input type="submit" value="确定" class='button' id='confirm_button'></td>
<td> <input type="reset" value = "重置" class = 'button' id = 'reset_button'></td>
</tr>
</table>
</form>
<script type="text/javascript">
$('#form1').submit(function(e){
var $username = $('input:eq(0)').val();
var $pa