dragon_sa
03-03-2012, 03:24 PM
I have this javascript function that shows the submit button when a file is selected in a form.
What I would like to do with that is add to the function so it checks the value selected in the file field to see if the last 4 characters are .jpg or .JPG if so show the submit button if not show error message which can be a dive set to hidden also at the start if needed
How do I do that?
the form code that invokes the script is
<input name="image_file" type="file" size="35" id="image_file" accept="image/jpeg" onchange="showDiv('submitDiv');return true;" onkeypress="return nokeys(event)">
and the current javascript function is
<script>
function showDiv(objectID) {
var theElementStyle = document.getElementById(objectID);
theElementStyle.style.visibility = "visible";
}
</script>
Thanks for your help
What I would like to do with that is add to the function so it checks the value selected in the file field to see if the last 4 characters are .jpg or .JPG if so show the submit button if not show error message which can be a dive set to hidden also at the start if needed
How do I do that?
the form code that invokes the script is
<input name="image_file" type="file" size="35" id="image_file" accept="image/jpeg" onchange="showDiv('submitDiv');return true;" onkeypress="return nokeys(event)">
and the current javascript function is
<script>
function showDiv(objectID) {
var theElementStyle = document.getElementById(objectID);
theElementStyle.style.visibility = "visible";
}
</script>
Thanks for your help