Link to home
Start Free TrialLog in
Avatar of maisaa alafghani
maisaa alafghani

asked on

Spry validation with file fields and there css

how do you validate a file field with the same validating features (CSS Styles)?

<tr valign="baseline">
            <td >Supporting documents:</td>
            <td colspan="2">
            <div class="required">
              <span>Uplode the file is required.</span>
           <!--   <label for="text1"></label>      -->
           <input type="file" name="file" value="" size="32">
                        </div></td>
          </tr>


so i need the spyr validation for file and the css validation for file
Avatar of David Johnson, CD
David Johnson, CD
Flag of Canada image

What is spyr validation? css validation is only applicable to css files or inline code
Avatar of maisaa alafghani
maisaa alafghani

ASKER

<tr valign="baseline">
            <td >Supporting documents:
                        </td>
            <td colspan="2">
                   
            <div class="required">
              <span id =spryfile>Uplode the file is required.</span>
       
           <input type="file" name="file" value="" size="32">
                        </div></td>
          </tr>
                  
                  <tr valign="baseline">
            <td nowrap align="right" valign="top">&nbsp;</td>
            <td colspan="2">&nbsp;</td>
          </tr>

<script>var spryfile = new Spry.Widget.Validationfile("spryfile");</script>
Spry is a javascript framework that used to ship with dreamweaver. I don't think it sill is shipped with adobe for probably the past 7 or 8 years. Even then it was outdated.  Look to using something else to validate like pure javascript, jquery or another framework like vue or angular.

For validation, there are typically two options.  One is on the client (using javascript) and the other is on the server (using back end code like php or asp).  Validating on the front end/client is optional.  The reason to validate first using javascript is it prevents too many calls to your server. For instance, you can validate a properly formatted email or make sure a field is filled in on the client/form/page before going to the server. However, javascript can be turned off or worked around because you do not have control over what happens on the user's machine (client).  Therefor, even if you validate on the client machine, you still need to validate data on the server using php/asp. Part of your data validation should also be ensuring nothing bad is going to be inserted to the database.

I suggest uninstalling spry from your project. Look at something like https://validatejs.org/.  If you go to the github page, https://github.com/ansman/validate.js you can see the last updates are very recent, within 4 months. Compare to spry https://github.com/adobe/Spry.  It shows depreciated and last updated 7 years.

What you will be validating is form data. Is that what you are expecting?
This question needs an answer!
Become an EE member today
7 DAY FREE TRIAL
Members can start a 7-Day Free trial then enjoy unlimited access to the platform.
View membership options
or
Learn why we charge membership fees
We get it - no one likes a content blocker. Take one extra minute and find out why we block content.