Im a total incompetent when it comes to JavaScript as i work soley in ASP and SQL, but against my better judgement tried some client side form validation the other day.
I wrote and hacked this together but it falls over.
Can you tell me whats up with it?
Thanks
Dave
function onSubmitForm() {
if (document.frmSend.attach.value == "")
alert("Please press the browse button and pick a file.")
else if (document.frmSend.attach.value != "")
{
var ext = document.frmSend.attach.value;
var VARext = new Array("doc","xls","ppt","PDF");
ext = ext.substring(ext.length-3,ext.length);
ext = ext.toLowerCase();
for (i = 0;i < VARext.length;i++)
{
if (ext == VARext)
return true;
else
alert('You selected a .'+ext+' file; please select a valid file instead!');
return false;
}
}
}
I wrote and hacked this together but it falls over.
Can you tell me whats up with it?
Thanks
Dave
function onSubmitForm() {
if (document.frmSend.attach.value == "")
alert("Please press the browse button and pick a file.")
else if (document.frmSend.attach.value != "")
{
var ext = document.frmSend.attach.value;
var VARext = new Array("doc","xls","ppt","PDF");
ext = ext.substring(ext.length-3,ext.length);
ext = ext.toLowerCase();
for (i = 0;i < VARext.length;i++)
{
if (ext == VARext)
return true;
else
alert('You selected a .'+ext+' file; please select a valid file instead!');
return false;
}
}
}