CF_FileInput

The <CF_FileInput> custom tags adds client-side JavaScript validation to the input type = "file" tag. It is similar to the CFINPUT tag. This is what the tag does:

  • Creates an input type = "file" field with the name you specify.
  • Creates JavaScript validation to make the field required if specified.
  • Creates JavaScript validation to only submit the form if the extension of the file is one that was specified.
  • Creates a hidden form field with the value of file name and path to the form field so you know what it is before the CFFILE tag is processed.

Syntax:

	<CF_FileInput Name="MyField" Required="yes" PassValue="yes" ValidExtensions="txt,doc">

onSubmit:

In order for the JavaScript to be processed when the form submits, an onSubmit event needs to be added to the form tag. The syntax of this event differs between HTML and CFML forms.

     CFML:

          <CFFORM ... onSubmit = "return CheckFileField(_CF_this)">

     HTML:

          <FORM ... onSubmit = "return CheckFileField(this)">

Test Form:

Select a file to upload and click the 'Upload' button. Only files with a .txt or .doc extension will be accepted.

There is no CFFILE tag to process the upload so the file you select will not be uploaded to the server.


Join Our E-Mail Newsletter

For Email Newsletters you can trust


Sister Sites

RiteTech LLC
Modern HOA