Now the problem is, whenever I clear my form, it changes my watermark color to #000 and I have no clue how to change it back to #888.
Javascript file
var HintClass = "hintTextbox";
var HintActiveClass = "hintTextboxActive";
// define a custom method on the string class to trim leading and training spaces
String.prototype.trim = function() {return this.replace(/^\s+|\s+$/g, '');};
function initHintTextboxes() {
var inputs = document.getElementsByTagName('input');
for (i=0; i<inputs.length; i++) {
var input = inputs[i];
if (input.type!="text" && input.type!="password")
continue;
if (input.className.indexOf(HintClass)!=-1) {
input.hintText = input.value;
input.className = HintClass;
input.onfocus = onHintTextboxFocus;
input.onblur = onHintTextboxBlur;
}
}
}
function onHintTextboxFocus() {
var input = this;
if (input.value.trim()==input.hintText) {
input.value = "";
input.className = HintActiveClass;
}
}
function onHintTextboxBlur() {
var input = this;
if (input.value.trim().length==0) {
input.value = input.hintText;
input.className = HintClass;
}
}
window.onload = initHintTextboxes;
CSS File
input.hintTextbox
{
color: #888;
}
input.hintTextboxActive
{
color: #000;
}
HTML form
<form name="maintainClientForm" action="http://localhost:8080/ILIAssembly-war/MaintainClientController" method="POST">
<table>
<tr>
<td> Name:</td>
<td><input type="text" id="name" name="name" value="Company Name" size="40" class="hintTextbox"></td>
<td></td>
</tr>
<tr>
<td>Address:</td>
<td><input type="text" name="address" value="Address" size="40" class="hintTextbox"></td>
<td></td>
</tr>
<tr>
<td>City:</td>
<td><input type="text" name="city" value="City" size="40" class="hintTextbox"></td>
<td></td>
</tr>
<tr>
<td>Province:</td>
<td><input type="text" name="province" value="Province" size="40" class="hintTextbox"></td>
<td></td>
</tr>
<tr>
<td>Country</td>
<td><input type="text" name="country" value="Country" size="40" class="hintTextbox"></td>
<td></td>
</tr>
<tr>
<td>Postal Code:</td>
<td><input type="text" name="postalCode" value="A1A2B2" size="6" maxlength="6" class="hintTextbox"></td>
<td></td>
</tr>
<tr>
<td>Phone Number:</td>
<td><input type="text" name="phoneNumber" value="1234567890" size="10" maxlength="10" class="hintTextbox"></td>
<td></td>
</tr>
<tr>
<td>Fax Number:</td>
<td><input type="text" name="faxNumber" value="Optional" size="10" maxlength="10" class="hintTextbox"></td>
<td></td>
</tr>
</table>
<table>
<tr>
<td valign="bottom" height="100px"><input class="button" type="submit" name="action" value="Add"></td>
<td valign="bottom" height="100px"><input class="button" type="submit" name="action" value="Update" disabled="true"></td>
<td valign="bottom" height="100px"><input class="button" type="submit" name="action" value="Delete" disabled="true"></td>
<td width="50px"></td>
<td valign="bottom" height="100px"><input class="button" type="submit" name="action" value="Search"></td>
<td valign="bottom" height="100px"><input class="button" type="reset" name="reset" value="Clear"/></td>
</tr>
</table>
</form>


Sign In
Create Account


Back to top










