如何在输入时和为空时验证密码字段(包括输入的空格)?
JS
$(document).ready(function()
{
$("#login_btn").click(function(){
if($("#pass").val() == "") {
$("#error").show("slow");
}
else if($("#pass").val() != "") {
$("#error").hide("slow");
}
});
});
HTML
<div id="login">
<div id="login_header"><h2>Sign in</h2></div>
<div id="dept">Department
<select>
<option value="CO" selected>CO</option>
</select>
</div>
<div id="pass">Password
<input type="password">
</div>
<div id="error">
Required field cannot be blank
</div>
<div id="btn">
<input type="button" value="Sign in" id="login_btn">
</div>
</div>