|
Hello,
I have the following script. The error message pops up but then when I click ok, the browser continues on to the result page. Is there a way just to alert and stay on the same page?
<form enctype="multipart/form-data" action="uploadimage.php" method="post" name="picture">
<input type="hidden" name="MAX_FILE_SIZE" value="100000" maxlength="15"/>
<input type="hidden" name="id" value="10025">
<table border="1" align="center">
<tr><td valign="top" width="590">Image file size must be less than 100 Kilobytes and be less than 200 px wide. Image format must be either JPG or GIF or animated GIF.
</td></tr>
<tr><td align="center">
<script type="text/javascript">
<!--
var photo
function formvalidation (photo)
{
var pict = document.picture.userfile.value;
if (pict.length >15 || pict.length <2) {
alert("Your file name must be less than 16 letters and more than 1 letter.");
}
else if (pict.search(/[^\w]/)>-1) {
alert("Your file name must be letters and numbers only");
}
}
</script>
Logo file: <input name="userfile" type="file" maxlength="15"/><br>Your file name can be letters and numbers only, without spaces.<br>
<input type="submit" value="Send Image File" onclick="formvalidation(photo)"/>
form>
Thanks,
Matt
|