Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    New Coder
    Join Date
    Jul 2005
    Posts
    83
    Thanks
    0
    Thanked 0 Times in 0 Posts

    check file extension in a form

    So I have a form...
    File: _______________ [Browse]
    Name: _____________
    [Submit]

    when person chooses file by browse button I want submit button to disable when file has extension that is not .txt or .doc
    how can I do that?

  • #2
    Senior Coder
    Join Date
    Mar 2005
    Location
    Portsmouth UK
    Posts
    4,534
    Thanks
    3
    Thanked 512 Times in 499 Posts
    Code:
    Enter the text and blur<br />
    Use your own method to call Ck()<br />
    <input  size="10"  onblur="Ck(this);" />
    
    <script language="JavaScript" type="text/javascript">
    /*<![CDATA[*/
    function Ck(obj){
     val=obj.value.substring(obj.value.length-4,obj.value.length);
     if (val!='.txt'&&val!='.doc'){
      alert(val+' is not .txt or .doc');
      return false;
     }
    }


  •  

    Posting Permissions

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