struts-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Puneet Lakhina" <puneet.lakh...@gmail.com>
Subject Re: Html:file - urgent
Date Wed, 20 Sep 2006 09:17:50 GMT
On 9/20/06, Raghuveer <raghuveerv@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

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message