Results 1 to 4 of 4

Thread: Validation

  1. #1
    Cosmo Kramer Guest

    Default Validation

    Have:<BR>&#060;FORM NAME=myform ONSUBMIT="Javascript validate()"&#062;<BR>&#060;INPUT TYPE=FILE NAME=myfile&#062;<BR>&#060;INPUT TYPE=SUBMIT NAME=mybttn&#062;<BR>&#060;/FORM&#062;<BR><BR>function validate()<BR>{<BR>if (document.myform.myfile.value.length==0)<BR>{alert ("Select a file");return false;}<BR>else<BR>{EXTRACT THE FILENAME FROM THE FULL PATH AND MAKE SURE THE FILENAME IS: Bill.pdf} if true alert("file <BR>is correct") else alert("Select Bill.pdf")<BR>}<BR><BR>2-Problems:<BR>1. Firstly how to extract the filename+extension from the full path?<BR>2. JScript is CASE-SENSITIVE, all of the following combinations of filename are CORRECT:<BR>bill.pdf, Bill.pdf, BIll.pdf,......(you get the picture)<BR><BR>help appreciated.

  2. #2
    Join Date
    Dec 1969

    Default RE: Validation

    use .toUpperCase() also that length test thing, spaces will break it unless you trim it.

  3. #3
    Dan Evans Guest

    Default RE: Validation

    To get the last part of a string like "/folder/file.ext" try splitting on the "/", then grabbing the last element:<BR><BR>var str = "blah/folder/file.ext";<BR>alert(str.split("/").reverse()[0]);<BR><BR>Hope this helps,<BR><BR>-Dan Evans

  4. #4
    Cosmo Kramer Guest

    Default RE: Validation --- THANKS


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts