开发者

Client-side Validation for Uploadify?

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.

  1. When your document loads, call validate() on your form.
  2. Start out with a textbox named myFileCollection that's blank and has class="required".
  3. Hook into the OnSelect event of Uploadify.
  4. 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.
  5. 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/

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜