I have a file input box that gets validated by javascript. I am testing the extension of the file to determine if it is a pdf. If not an alert box should be thrown.
After the alert box is thrown and the user clicks OK I want the input field to clear and the bad value removed.
Here is what I have so far:
function check(file) {
ext = file.substring(file.lastIndexOf('.')+1);
if (ext != "pdf"
{
alert("You must upload document in Adobe PDF format..."
;
event.returnValue=false; }
}
<input type="File" name="attach1" onpropertychange="check(this.value);">
How do I clear the field?
After the alert box is thrown and the user clicks OK I want the input field to clear and the bad value removed.
Here is what I have so far:
function check(file) {
ext = file.substring(file.lastIndexOf('.')+1);
if (ext != "pdf"
alert("You must upload document in Adobe PDF format..."
event.returnValue=false; }
}
<input type="File" name="attach1" onpropertychange="check(this.value);">
How do I clear the field?