Hi,
I am using 3 different types of plugin to validate a form, such as below,
http://lauthiamkok.net/tmp/jquery/multifiles/form.php
below is the source of these plugins,
http://malsup.com/jquery/form/
http://onehackoranother.com/projects/jquery/jquery-grab-bag/input-hint.html
in using ‘multiple-file-upload’, you can use the maxlength property if you want to limit the number of files selected,
<form action="process.php" method="post" id="my-form" enctype="multipart/form-data">
<p>E-mail<br />
<input type="text" name="email" id="email" title="email"/></p>
<p>File<br />
<input type="file" name="upload[]" id="upload" class="multi" accept="gif|jpg" maxlength="2"/></p>
<p><input type="submit" value="Submit" /></p>
</form>
it works fine until i have installed the other two plugins - jquery form and input hint.
now, whenever after I hit the submit button, the browse button appears to be able for selecting as many files as you wish even though I have limited the number in the file input field - maxlength=“2”.
first I found out that it was caused by the jquery form plugin, so then i tried to use if condition to disable the browse input button, but it still wont work,
if($('input[type=file]').length >= 3)
{
alert('hide me!');
//$('input:file').MultiFile('reset');
$('input[title]').inputHint();
$('input[type=file]').attr('disabled', 'disabled');
}
and I have found that it is actually the input hint causing that!
any ideas how to fix this??
the entire code is this,
$(document).ready(function() {
$('input[title]').inputHint();
$('#my-form').submit(function() {
$(this).ajaxSubmit({
target: '#output',
// dataType: 'xml',
// success identifies the function to invoke when the server response
// has been received
success: function() {
alert($('input[type=file]').length);
if($('input[type=file]').length >= 3)
{
alert('hide me!');
//$('input:file').MultiFile('reset');
$('input[title]').inputHint();
$('input[type=file]').attr('disabled', 'disabled');
}
}
});
return false;
});
});
many thanks,
Lau