I am working on a page which uses uploadify to upload several images. The requires the user to upload these files. Is there a way to validate these field(s) on 开发者_Python百科the client-side, such as with jQuery or JavaScript, prior to submission? I am comfortable with doing the server-side validation, such as with PHP.
Thank you for your time.
Sure thing. You can just use the basic validate plugin but you have to manually mirror over what uploadify is bringing back. So there are many ways to do this but here's how you'd get started.
- When your document loads, call validate() on your form.
- Start out with a textbox named
myFileCollection
that's blank and hasclass="required"
. - Hook into the
OnSelect
event of Uploadify. - For each file selected through Uploadify, change the value in myFileCollection to the count of files. If it's zero, blank out the text box.
- Ignore the textbox when you submit
This way, the form would have a way to keep track of what Uploadify is up to. Check out the event documentation of Uploadify for info on how / where to hook in:
http://www.uploadify.com/documentation/events/onselect/
精彩评论