by Matt Coughlin

setDefaultInputText:

Goal:

Add default text to an edit box or textarea.

Allow support for screen readers.

Example:

Implementation notes:

HTML:

<input type="text" id="firstName" name="firstName" value="" size="20" maxlength="30" />
<input type="text" id="lastName" name="lastName" value="" size="20" maxlength="30" />

<textarea id="comments" name="comments"><textarea>
        

JavaScript:

setDefaultInputText('#firstName', 'First Name');
setDefaultInputText('#lastName', 'Last Name');

setDefaultInputText('#comments', 'Enter your comments');
        

setDefaultInputText.js