You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Abhimanyu Koul <ab...@fineng.com> on 2006/09/20 09:49:13 UTC
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
Re: Html:file - urgent
Posted by Puneet Lakhina <pu...@gmail.com>.
On 9/20/06, Raghuveer <ra...@infotechsw.com> wrote:
>
>
>
>
>
> /***************************************************************************
> ***
> * 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)" />
The user can enter the File name by pasting using mouse.
var filename = document.Form.theFile.value;
>
> var filename = document.smiAttachmentForm.theFile.value;
> var varQuizCourseCode;
> var onlyFileName =
> filename.substring(filename.lastIndexOf("\\")+1,
> filename.length);
This is windows specific. And basically I think all that the guy wants to
check if the field is blank. So just check
if(control.value = "") {
alert("No File Selected");
}
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:abhimanyu_koul@fineng.com]
> 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: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
>
>
--
Puneet
RE: Html:file - urgent
Posted by Raghuveer <ra...@infotechsw.com>.
/***************************************************************************
***
* 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:abhimanyu_koul@fineng.com]
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: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org
RE: Html:file - urgent
Posted by "Patil, Sheetal" <pa...@diebold.com>.
YOU CANT CHECK B'COZ JAVASCRIPT DOSENT ALLOW U TO READ THE FILE ON DISC.
You can do
1. <html:file property="ffff" onkeydown="javascript:return false;"/>
//it causes that no user can enter data manually, rather he has to
select using brows button
2. check in javascript wheather that field is empty or not
-----Original Message-----
From: Abhimanyu Koul [mailto:abhimanyu_koul@fineng.com]
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: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org