added validation for uploading a photo. Users must select a photo before they hit the upload button.

This commit is contained in:
mb863 2010-07-01 19:10:34 +00:00
parent 98b71db1f4
commit e50507efee
2 changed files with 24 additions and 1 deletions

View file

@ -0,0 +1,21 @@
function validate_upload_file(form_passed) {
var msg="";
if (form_passed.datafile.value == "") msg += "Please browse and select a photo\n";
if (msg == "") {
document.form_upload_image.submit();
} else{
alert(msg);
return false;
}
}

View file

@ -2,6 +2,8 @@
<#-- Upload a replacement main image for an Individual. --> <#-- Upload a replacement main image for an Individual. -->
${scripts.add("/js/imageUpload/validateUpload.js")}
${stylesheets.addFromTheme("/uploadImages.css")} ${stylesheets.addFromTheme("/uploadImages.css")}
<#if errorMessage??> <#if errorMessage??>
@ -14,7 +16,7 @@ ${stylesheets.addFromTheme("/uploadImages.css")}
<h6>Current Photo</h6> <h6>Current Photo</h6>
<img src="${thumbnailUrl}" width="115" height="115" /> </div> <img src="${thumbnailUrl}" width="115" height="115" /> </div>
<div id="photoUploadForm"> <div id="photoUploadForm">
<form action="${formAction}" enctype="multipart/form-data" method="post"> <form action="${formAction}" enctype="multipart/form-data" method="post" onSubmit="return validate_upload_file(this)">
<label>Upload a photo <span> (JPEG, GIF or PNG. Max Size: 50 MB)</span></label> <label>Upload a photo <span> (JPEG, GIF or PNG. Max Size: 50 MB)</span></label>
<input type="file" name="datafile" size="30"> <input type="file" name="datafile" size="30">
<input type="submit" value="Upload photo"> or <a href="${cancelUrl}">Cancel</a> <input type="submit" value="Upload photo"> or <a href="${cancelUrl}">Cancel</a>