Posted By

1man on 01/22/09


form javascript select input jquery ux ue

Versions (?)

Who likes this?

3 people have marked this snippet as a favorite


jQuery Input value select

 / Published in: JavaScript

Click on an input field with a prefilled value, if that value equals the default then select it, if not leave it as it was. Relies on jQuery.

  1. $("input[name=forname], input[name=surname]").focus(function(){
  2. var defaultText = $(this).val();
  3. if(defaultText === "Forename" || defaultText === "Surname"){
  4. $(this).select();
  5. }
  6. });

Report this snippet  

You need to login to post a comment.