PHP Web Developer.

สิงหาคม 15, 2012

jQuery: Textbox Validation and the blur() Event

Filed under: Javascript & jquery — Prajak @ 6:04 pm

<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>


        var username_length; 
        username_length = $("#txt_username").val().length; 
        if (username_length < 4) 
            $("#username_warning").append("Username is too short"); 
        var password_length; 
        password_length = $("#txt_password").val().length; 
        if (password_length < 6) 
            $("#password_warning").append("Password is too short"); 

ให้ความเห็น »


RSS feed for comments on this post. TrackBack URI


Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  เปลี่ยนแปลง )

Google+ photo

You are commenting using your Google+ account. Log Out /  เปลี่ยนแปลง )

Twitter picture

You are commenting using your Twitter account. Log Out /  เปลี่ยนแปลง )

Facebook photo

You are commenting using your Facebook account. Log Out /  เปลี่ยนแปลง )


Connecting to %s


%d bloggers like this: