I had a form like below that validated that a file was there before it
would submit.
<form name="attach" method="POST" action="run_thi s_pgm.cfm"
enctype="multip art/form-data" onSubmit="retur n(validateData( this))">
<input type="file" name="txtFileTo Upload">
<input type="submit" name="btnAdd" value="Add" class="form_but ton">
</form>
function checkFile(frm)
{
var strLength = frm.txtFileToUp load.value.leng th;
var min = 5;
if (strLength < min)
{
alert("Please choose a valid file to upload.");
frm.txtFileToUp load.focus();
frm.txtFileToUp load.select();
return false;
}
}
function validateData(fr m)
{
return (checkFile(frm) )
}
I wanted to change it to submit in a popup window instead and not open
the new window unless a valid file exists. I made these changes below
but it does not work. Somehow I need to check the existence of the file
and not just that a string is in the textbox.
<form name="attach" method="POST" action="run_thi s_pgm.cfm"
enctype="multip art/form-data">
<input type="file" name="txtFileTo Upload">
<button name="btnAdd" onclick="save_a ttach(this.form );">Add</button>
</form>
function save_attach(frm )
{
if ( validateData(fr m) )
{
alert('should be ok');
}
}
Any help is appreciated.
Mike