/***************************************************************************
***
* Function name : checkFile
* Description : This function is to stop the user from entering a file
name
* Input :
* Output :
****************************************************************************
**/
function checkFile(fname){
fname.select();
alert(" Please use the ' Browse... ' button to select the file
");
}
<html:file property="theFile" onkeydown="checkFile(this)" />
var filename = document.Form.theFile.value;
var filename = document.smiAttachmentForm.theFile.value;
var varQuizCourseCode;
var onlyFileName =
filename.substring(filename.lastIndexOf("\\")+1,
filename.length);
var onlyExtension =
filename.substring(filename.lastIndexOf(".")+1,
filename.length);
var varExten =
onlyExtension.toUpperCase();
var varFileStatus=false;
if
(document.smiAttachmentForm.documnetType[0].selected == true){
alert('<bean:message
key="msg.customer.supplied.records.document"/>');
document.smiAttachmentForm.documnetType.focus();
return;
}
if(funTrim(filename)=="" ){
alert('<bean:message
key="msg.customer.supplied.records.document.invalid.operation"/>');
document.smiAttachmentForm.theFile.select();
document.smiAttachmentForm.theFile.focus();
return;
}else{
filename =
filename.split("\\");
if(
(filename[filename.length-1]).length<3){
alert('<bean:message
key="msg.customer.supplied.records.document.invalid.file"/>');
document.smiAttachmentForm.theFile.select();
document.smiAttachmentForm.theFile.focus();
return;
}else if
(isWhitespace(document.smiAttachmentForm.theFile.value)){
alert('<bean:message
key="msg.customer.supplied.records.document.invalid.operation"/>');
document.smiAttachmentForm.theFile.select();
document.smiAttachmentForm.theFile.focus();
return;
// filename
check is set to only 40 character to limit for renaming
of file
// in database
its length limited to 50 characters
}else if(
(filename[filename.length-1]).length>40){
alert('<bean:message
key="msg.customer.supplied.records.document.invalid.file.length"/>');
document.smiAttachmentForm.theFile.select();
document.smiAttachmentForm.theFile.focus();
return;
}
}
-----Original Message-----
From: Abhimanyu Koul [mailto:[EMAIL PROTECTED]
Sent: Wednesday, September 20, 2006 1:19 PM
To: Struts Mailing list
Subject: Html:file - urgent
Hi!
Please tell me how can i use javascript to check that the user has not
selected any file in the html:file tag.
Koul
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]