Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    Regular Coder
    Join Date
    Dec 2008
    Posts
    117
    Thanks
    14
    Thanked 0 Times in 0 Posts

    jquery: multiple file upload + jquery form + input hint

    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://www.fyneworks.com/jquery/multiple-file-upload/
    http://malsup.com/jquery/form/
    http://onehackoranother.com/projects...nput-hint.html

    in using 'multiple-file-upload', you can use the maxlength property if you want to limit the number of files selected,

    Code:
    <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,

    Code:
    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,

    Code:
    $(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

  • #2
    Senior Coder Spudhead's Avatar
    Join Date
    Jun 2002
    Location
    London, UK
    Posts
    1,856
    Thanks
    8
    Thanked 110 Times in 109 Posts
    Aha. You're a spammer. Do go away, there's a good chap.


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •