Input FileUpload required Property - Set a file upload field to be a required part of form submission: - Javascript DOM HTML Element

Javascript examples for DOM HTML Element:Input FileUpload

Description

Input FileUpload required Property - Set a file upload field to be a required part of form submission:

Demo Code

ResultView the demo in separate window

<!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>

Related Tutorials