M
mike
I had a form like below that validated that a file was there before it
would submit.
<form name="attach" method="POST" action="run_this_pgm.cfm"
enctype="multipart/form-data" onSubmit="return(validateData(this))">
<input type="file" name="txtFileToUpload">
<input type="submit" name="btnAdd" value="Add" class="form_button">
</form>
function checkFile(frm)
{
var strLength = frm.txtFileToUpload.value.length;
var min = 5;
if (strLength < min)
{
alert("Please choose a valid file to upload.");
frm.txtFileToUpload.focus();
frm.txtFileToUpload.select();
return false;
}
}
function validateData(frm)
{
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_this_pgm.cfm"
enctype="multipart/form-data">
<input type="file" name="txtFileToUpload">
<button name="btnAdd" onclick="save_attach(this.form);">Add</button>
</form>
function save_attach(frm)
{
if ( validateData(frm) )
{
alert('should be ok');
}
}
Any help is appreciated.
Mike
would submit.
<form name="attach" method="POST" action="run_this_pgm.cfm"
enctype="multipart/form-data" onSubmit="return(validateData(this))">
<input type="file" name="txtFileToUpload">
<input type="submit" name="btnAdd" value="Add" class="form_button">
</form>
function checkFile(frm)
{
var strLength = frm.txtFileToUpload.value.length;
var min = 5;
if (strLength < min)
{
alert("Please choose a valid file to upload.");
frm.txtFileToUpload.focus();
frm.txtFileToUpload.select();
return false;
}
}
function validateData(frm)
{
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_this_pgm.cfm"
enctype="multipart/form-data">
<input type="file" name="txtFileToUpload">
<button name="btnAdd" onclick="save_attach(this.form);">Add</button>
</form>
function save_attach(frm)
{
if ( validateData(frm) )
{
alert('should be ok');
}
}
Any help is appreciated.
Mike