Javascript examples for DOM HTML Element:Input FileUpload
Input FileUpload required Property - Set a file upload field to be a required part of form submission:
<!DOCTYPE html> <html> <body> <form action="#"> Select a file: <input type="file" id="myFile" name="usr_file"> <input type="submit"> </form>//w w w. ja v a 2 s . co m <button onclick="myFunction()">Test</button> <p id="demo"></p> <script> function myFunction() { document.getElementById("myFile").required = true; document.getElementById("demo").innerHTML = "The required property was set."; } </script> </body> </html>