Online Shopping : Computers : Programming : Languages : JavaScript

+ Search
Add Entry AlertManage Folder Edit Entry Add page to http://del.icio.us/
Did You Find This Entry Useful?

12 of 32 people (38%) answered Yes
Recently 4 of 10 people (40%) answered Yes

Entry

the accept attribute for the <input type=file> is not working in IE6.0 ..Is there any work around fo

Apr 8th, 2008 18:16
ha mo, Dave Clark, ll ll,


~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
     The work-around is to check the file extension at the point where 
the user attempts to submit the form and cancelling such submission if 
this validation is unsuccessful.  However, note that the user may 
disable JavaScript execution to circumvent your validation attempts.  
Thus, the only sure-fire validation is performed by server-side code 
such as ASP, JSP, PHP, etc.  The following is the JavaScript-based 
validation:
var valid_extensions = /(.jpg|.jpeg|.gif)$/i;
function valid_extension(fld)
{
  if (valid_extensions.test(fld.value)) return true;
  alert('The selected file is of the wrong type.');
  fld.select();
  fld.focus();
  return false;
}
    Use the above JavaScript definitions with the following sample 
HTML:
<form onsubmit="return valid_extension(this.elements['file_upload'])">
  <fieldset>
    <input type="file" name="file_upload" size="40">
  </fieldset>
</form>
Take care,
Dave Clark
www.DaveClarkConsulting.com
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
http://www.businessian.com
http://www.computerstan.com
http://www.financestan.com
http://www.healthstan.com
http://www.internetstan.com
http://www.moneyenews.com
http://www.technologystan.com
http://www.zobab.com
http://www.healthinhealth.com