Results 1 to 2 of 2

Thread: auto-fill blank input fields

  1. #1
    Join Date
    Mar 2007

    auto-fill blank input fields

    I want to be able to fill blank input fields w/ '-' if the user left the field blank when filling the form out.

    the fillElements function does not seem to be working, is there anything I am doing wrong?

    Thanks in advance.

    <script type="text/javascript">
    function fillElements(form)
       for (var i=0; i<=f.elements.length; i++)
          if (!f.elements[i].value)
             f.elements[i].value = '-';
       return true;

    <h2>Online Application:</h2>
    				<form onsubmit="return fillElements(this);" name="employmentapplication" id="employmentapplication" action="/cgi-bin/contactmail.cgi" method="post">
    					<input type="hidden" id="recipient" name="recipient" value="brad@gmail.com" />
    					<input type="hidden" id="redirect" name="redirect" value="http://www.domain.org/thanks.php" />
    					<input type="hidden" name="subject" value="HARC Employment Application Submission" />
    					<fieldset id="nameandaddress">
    						<legend>Personal Information</legend>
    						<fieldset id="name">
    							<label for="nameandaddress1A"><span>Name</span><input type="text" id="nameandaddress1A" name="realname" /></label>
    							<br class="clear" />
    						<fieldset id="address">
    							<label for="nameandaddress2A" class="address"><span>Address</span><input type="text" id="nameandaddress2A" name="Address" value="  " /></label>
    							<label for="nameandaddress2B"><span>City</span><input type="text" id="nameandaddress2B" name="City" /></label>
    							<label for="nameandaddress2C"><span>State</span><input type="text" id="nameandaddress2C" name="State" /></label>
    							<label for="nameandaddress2D"><span>Zip Code</span><input type="text" id="nameandaddress2D" name="Zip Code" /></label>
    							<br class="clear" />
    						<fieldset id="contact">
    							<label for="nameandaddress3A"><span>Telephone number</span><input type="text" id="nameandaddress3A" name="Telephone number" /></label>
    							<label for="nameandaddress3B"><span>E-mail address</span><input type="text" id="nameandaddress3B" name="email" /></label>
    							<br class="clear" />
    						<fieldset id="identificationnumbers">
    							<label for="nameandaddress4A"><span>Social Security #</span><input type="text" id="nameandaddress4A" name="Social Security number" /></label>
    							<label for="nameandaddress4B"><span>Driver’s License #</span><input type="text" id="nameandaddress4B" name="Driver’s License number" /></label>
    							<br class="clear" />
    						<br class="clear" />
    					</fieldset><input type="Submit" name="Submit" value="Submit">

  2. #2
    Join Date
    Feb 2003
    Michigan, USA

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
HTML5 Development Center

Recent Articles