Wednesday 15 April 2009

Image validation

function checkPhoto(imagePath) {
var pathLength = imagePath.length;
var lastDot = imagePath.lastIndexOf(".");
var fileType = imagePath.substring(lastDot,pathLength);

if((fileType == ".gif") || (fileType == ".jpg") || (fileType == ".png") || (fileType == ".GIF") || (fileType == ".JPG") || (fileType == ".PNG")) {
return true;
} else {
alert("We supports .JPG, .PNG, and .GIF image formats. Your file-type is " + fileType + ". If you are having difficulties with this step, please send an e-mail to trevor@trevor.net.");
}
}

No comments:

Post a Comment