Forums
This topic is locked
ASP Upload - validating on submit
Posted 02 May 2003 13:28:30
1
has voted
02 May 2003 13:28:30 Brendan Collins posted:
HiI am trying to get the validation code for Pure ASP Upload working. I have a form with two file fields on it, one for a source document which must be in word format and one for an image which must be gif or jpg.
I have the following event placed on my insert button on the page:
onClick="checkOneFileUpload(filDoc,'DOC',true,'','','','','','','');checkOneFileUpload(filImage,'GIF,JPG,JPEG',true,'','','','','','','');return document.MM_returnValue;FDK_Validate('frmIns',true,false,'The Form Could Not Be Submitted');return document.MM_returnValue"
This works fine if the 'filImage' file field is invalid, but if it is valid then the code ignores the 'filDoc' file validation code. I think the problem is that the 'return document.MM_returnValue' code is coming after the 'filImage' validation call and therefore only depends on what it returns.
Anyone have any ideas.
Any help is much appreciated.
Thanks
Brendan<font color=red></font id=red><font color=yellow></font id=yellow><font color=black></font id=black>
Replies
Replied 06 May 2003 10:35:54
06 May 2003 10:35:54 Patrick Woldberg replied:
On which tag is this event, normally Pure ASP Upload would use the onchange event of the file input fields, then both fields will be checked directly if a file has been choosen. The form tag should contain the checkFileUpload action on the onSubmit action, this will also check all the filefields.
So try adding the behaviours directly the file input fields.
--------------------------------------------------
Patrick Woldberg
Web Developer at Dynamic Zones
Manager at DMXzone.com
--------------------------------------------------
So try adding the behaviours directly the file input fields.
--------------------------------------------------
Patrick Woldberg
Web Developer at Dynamic Zones
Manager at DMXzone.com
--------------------------------------------------
Replied 06 May 2003 11:11:29
06 May 2003 11:11:29 Brendan Collins replied:
Patrick
Thanks for the reply.
I already have the checkOneFileUpload() code on the onChange event of each of the file fields. The problem is that when I click ok on the error message which appears, the path and filename are still visible inside the file fields. This then allows the user to click submit and the invalid filename is still sent.
I have the checkFileUpload action on the onSubmit of the form, but due to each file form object accepting different file types, this validation will only cover a combination of the two valid types.
This means that if I only accepted .doc extension in the first file field and only .gif in the second, then should the user place a .gif in the first file field and a .doc in the second, the form would still get submitted.
Hope you can follow what I am trying to say in the above.
Thanks
Brendan
Thanks for the reply.
I already have the checkOneFileUpload() code on the onChange event of each of the file fields. The problem is that when I click ok on the error message which appears, the path and filename are still visible inside the file fields. This then allows the user to click submit and the invalid filename is still sent.
I have the checkFileUpload action on the onSubmit of the form, but due to each file form object accepting different file types, this validation will only cover a combination of the two valid types.
This means that if I only accepted .doc extension in the first file field and only .gif in the second, then should the user place a .gif in the first file field and a .doc in the second, the form would still get submitted.
Hope you can follow what I am trying to say in the above.
Thanks
Brendan
Replied 06 May 2003 11:14:14
06 May 2003 11:14:14 Brendan Collins replied:
I suppose what I really need is what code could I place inside the checkOneFileUpload() function, and where, which would clear the file form object if there is an invalid filetype entered.
Thanks
Brendan
Thanks
Brendan
Replied 06 May 2003 13:54:29
06 May 2003 13:54:29 Brendan Collins replied:
Hi
Solved the problem by placing the calls to the checkOneFileUpload() function inside another function as follows:
function valform(){
if (!checkOneFileUpload(form1.filImageDoc,'PNG,VSD,PPS,PPT',true,'','','','','','',''))
{
return false;
}
if(!checkOneFileUpload(form1.filMap,'GIF,JPG,JPEG',true,'','','','','','',''))
{
return false;
}
}
Solved the problem by placing the calls to the checkOneFileUpload() function inside another function as follows:
function valform(){
if (!checkOneFileUpload(form1.filImageDoc,'PNG,VSD,PPS,PPT',true,'','','','','','',''))
{
return false;
}
if(!checkOneFileUpload(form1.filMap,'GIF,JPG,JPEG',true,'','','','','','',''))
{
return false;
}
}
Replied 06 May 2003 16:03:30
06 May 2003 16:03:30 Patrick Woldberg replied:
Great to hear it is all solved.
--------------------------------------------------
Patrick Woldberg
Web Developer at Dynamic Zones
Manager at DMXzone.com
--------------------------------------------------
--------------------------------------------------
Patrick Woldberg
Web Developer at Dynamic Zones
Manager at DMXzone.com
--------------------------------------------------