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 4 of 4
  1. #1
    Regular Coder
    Join Date
    Sep 2007
    Posts
    179
    Thanks
    4
    Thanked 0 Times in 0 Posts

    Question ASP JS good stuff

    this is a wonderful asp js that checking that only pdf files will upload
    Code:
    <script language=vbscript>
    sub Checkform()
    
    if lcase(right(myfrm.file.value,4)) <> ".pdf" then
    alert "not pdf File.Size"
    myfrm.reset()
    end if
    end sub
    </script>
    
    <form action=addAttachment.asp enctype="multipart/form-data" method=post name=myfrm id=myfrm>
    <input type=file name=file id=file onchange="Checkform()">
    <input type=button value="add file">
    </form>
    i want to export it to jpg and gifs

    Code:
    <script language=vbscript>
    sub Checkform()
    
    
    if lcase(right(myfrm.file.value,4)) <> ".pdf" and lcase(frm.file.value,3)) <> ".jpg" and lcase(right(myfrm.file.value,3)) <> "jpeg" then
    alert "not pdf File.Size"
    myfrm.reset()
    end if
    end sub
    </script>
    
    <form action=addAttachment.asp enctype="multipart/form-data" method=post name=myfrm id=myfrm>
    <input type=file name=file id=file onchange="Checkform()">
    <input type=button value="add file">
    </form>
    i thought that if i will add and\or in the "if", i will solve this...but as you see i was wrong...can you help me?

    by the way if someone knows how to check the size of the choosen file in this stage i will be happy like a little girl!
    Last edited by sasha85; 09-28-2007 at 05:11 AM.

  • #2
    Regular Coder
    Join Date
    Sep 2007
    Posts
    120
    Thanks
    0
    Thanked 3 Times in 3 Posts
    Hi,

    Try this:

    <script type="text/javascript">
    function Checkform() {
    var o = document.getElementById('file');
    var ex = o.value.substring(o.value.lastIndexOf('.')+1);
    if(ex.toLowerCase() == 'gif' || ex.toLowerCase() == 'jpg' || ex.toLowerCase() == 'pdf') {
    return true;
    }
    else {
    alert('extension not allowed');
    return false;
    }
    }
    </script>

    <form action="addAttachment.asp" enctype="multipart/form-data" method="post" name="myfrm" id="myfrm" onSubmit="return Checkform();">
    <input type="file" name="file" id="file">

    <input type="submit" value="add file">
    </form>

    HTH, AA

  • #3
    Regular Coder
    Join Date
    Sep 2007
    Posts
    179
    Thanks
    4
    Thanked 0 Times in 0 Posts

    mmmm

    man it's realy good!
    Last edited by sasha85; 09-28-2007 at 02:50 PM.

  • #4
    Regular Coder
    Join Date
    Sep 2007
    Posts
    179
    Thanks
    4
    Thanked 0 Times in 0 Posts

    Thumbs up Tom

    never mind i will use the first script only
    Last edited by sasha85; 09-29-2007 at 03:33 AM.
    By the time u recognize this moment, This moment will be gone.


  •  

    Posting Permissions

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