/ 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.
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
$("input[name=forname], input[name=surname]").focus(function(){ var defaultText = $(this).val(); if(defaultText === "Forename" || defaultText === "Surname"){ $(this).select(); } });
Comments
