<b>Username:</b> <i>Username must be at least 4 characters in length</i>
<input type=”text” id=”txt_username” name=”username”>
<span id=”username_warning” style=”color:red”></span>
<b>Password:</b> <i>Password must be at least 6 characters in length</i>
<br><input type=”password” id=”txt_password” name=”password”>
<span id=”password_warning” style=”color:red”></span>
$(document).ready(function(){
$("#txt_username").blur(function()
{
var username_length;
username_length = $("#txt_username").val().length;
$("#username_warning").empty();
if (username_length < 4)
$("#username_warning").append("Username is too short");
});
$("#txt_password").blur(function()
{
var password_length;
password_length = $("#txt_password").val().length;
$("#password_warning").empty();
if (password_length < 6)
$("#password_warning").append("Password is too short");
});
});
ใส่ความเห็น