[jQuery] Re: limit to only jpeg when file upload

2007-11-16 Thread dfgonzalez
This works fine, except for the toLowerCase() function thar throws an error, if you remove that it's just fine. On Oct 31, 7:11 pm, Erik Beeson [EMAIL PROTECTED] wrote: Untested: form method=POST action=... input id=file name=file type=file /form $('form').bind('submit', function() {

[jQuery] Re: limit to only jpeg when file upload

2007-10-31 Thread Andy Matthews
You could split on ., then check last index of the resulting array: $('#file').val().split('.').slice(-1); should return jpg, gif, etc. -Original Message- From: jquery-en@googlegroups.com [mailto:[EMAIL PROTECTED] On Behalf Of [EMAIL PROTECTED] Sent: Wednesday, October 31, 2007 10:32

[jQuery] Re: limit to only jpeg when file upload

2007-10-31 Thread Giovanni Battista Lenoci
[EMAIL PROTECTED] ha scritto: Hi, I'm using this to upload file: input id=file name=file type=file It works very well, now I'd like to find a way to check only jpeg files are uploaded, any way to do this in jQuery? Thanks. A.C. I think the only thing you can do client-side is to

[jQuery] Re: limit to only jpeg when file upload

2007-10-31 Thread [EMAIL PROTECTED]
so where to attach the code? in the onClick of submit button? On Nov 1, 12:04 am, Giovanni Battista Lenoci [EMAIL PROTECTED] wrote: [EMAIL PROTECTED] ha scritto: Hi, I'm using this to upload file: input id=file name=file type=file It works very well, now I'd like to find a way to

[jQuery] Re: limit to only jpeg when file upload

2007-10-31 Thread Erik Beeson
Untested: form method=POST action=... input id=file name=file type=file /form $('form').bind('submit', function() { var ext = $('#file').val().split('.').slice(-1).toLowerCase(); if(ext != 'jpg' ext != 'jpeg') { alert('JPEG Only'); return false; } }); --Erik On 10/31/07,

[jQuery] Re: limit to only jpeg when file upload

2007-10-31 Thread Flesler
Or instead of splitting: $('form').bind('submit', function() { if(! /\.jpe?g$/i.test( this.file.value )){ alert('JPEG Only'); return false; } }); On 31 oct, 19:11, Erik Beeson [EMAIL PROTECTED] wrote: Untested: form method=POST action=... input id=file name=file type=file