Hi my problem is that i have a form that expands dynamically. I will use it to upload the files to e-commerce website to upload the products pictures, i want to limit the size and filter the extensions before upload, but i am a noob with javascript, and/or jQuery...
i need help to validate those, because i think i can handle the PHP side of things :) here is my experimental code:
<script language="Javascript" type="text/javascript"> var counter = 1; var limit = 10; function addInput(divName){ if (counter == limit) { alert("You have reached the maximum of " + counter + " fotos"); } else { var newdiv = document.createElement('div'); newdiv.innerHTML = "Foto " + (counter + 1) + " <br><input type='file' name='myInputs[]'>"; document.getElementById(divName).appendChild(newdiv); counter++; } } </script> <form method="POST" enctype="multipart/form-data"> <div id="dynamicInput"> Foto 1<br><input type="file" name="myInputs[]"> </div> <input type="button" value="Add more fotos" onClick="addInput('dynamicInput');"> </form>
thank you in advance
EDIT:
ok i can verify the type of files submitted but i cannot loop through the different file fields...
i have this code on fiddle http://jsfiddle.net/Glink/sGCeK/
it may help you help me...
one more question, if i have my code in xHTML is it very hard to update to HTML5?
once again thank you in advance...