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, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote: > > > 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 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 check the extension. > > > > $pieces = $('#file')[0].value.split('.'); > > $extension = $pieces[$pieces.length-1].toLowerCase(); > > if($extension == 'jpg' || $extension == 'jpeg') { > > alert('accepted'); > > > > } > >