Page 1 of 2 12 LastLast
Results 1 to 10 of 13

Thread: validation for <INPUT TYPE="FILE">

  1. #1
    Join Date
    Jun 2006
    Posts
    6
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Cool validation for <INPUT TYPE="FILE">

    yo yo

    can we validate the <INPUT TYPE="FILE">?

    WHILE UPLOADING A FILE I NEED TO RESTRICT THE USER FROM ENTERING TEXT DIRECTLY IN THE TEXT FIELD AND SOME FILE VALIDATION HAS TO BE DONE

    help me out in handling

  2. #2
    Join Date
    Jun 2006
    Posts
    11
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Hi Pradeeh,

    You can restrict the user entering file name directly to the textbox by writing a Keypress event as

    Script

    <script language="javascript" >
    function onkeyPress(e)
    {
    var key = window.event ? e.keyCode : e.which;
    if (key == 13)
    StartClick();
    e.cancelBubble = true;
    e.returnValue = false;
    return false;
    }
    </script>

    Html

    <input id="File1" style="position: relative" type="file" onkeypress="return onkeyPress(event);">

    Can u be still clear on the other validation to be done.

    Regards,

    Valli

    (www.syncfusion.com)

    ASP.Net FAQ:
    http://www.syncfusion.com/faq/aspnet/default.aspx

    Complete set of ASP.Net controls and components
    http://www.syncfusion.com/toolsweb
    Valli

  3. #3
    Join Date
    Jun 2005
    Location
    英国
    Posts
    11,876
    Thanks
    1
    Thanked 180 Times in 172 Posts
    Blog Entries
    2

    Default

    It ought to be done server-side. And what kind of validation are you talking about?

    PHP FAQ:
    http://www.php.net/FAQ.php

    Complete set of PHP functions
    http://www.php.net/manual/en/funcref.php
    Twey | I understand English | 日本語が分かります | mi jimpe fi le jbobau | mi esperanton komprenas | je comprends français | entiendo español | tôi ít hiểu tiếng Việt | ich verstehe ein bisschen Deutsch | beware XHTML | common coding mistakes | tutorials | various stuff | argh PHP!

  4. #4
    Join Date
    Jun 2006
    Posts
    6
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    valli

    my requirement is that the use sudn't even enter a valida path. he has options only to select a file and on uploading [clicking the button] it has to check whether a file is been selected.


    Twey

    NO SERVER_SIDE VALIDATION...

    PraDheep

  5. #5
    Join Date
    Mar 2006
    Location
    Illinois, USA
    Posts
    12,164
    Thanks
    265
    Thanked 690 Times in 678 Posts

    Default

    my requirement is that the use sudn't even enter a valida path.
    Whoa, huh?

    Note that whatever you want for this validation, you'll still need something serverside to recieve the file, so... sure, add a user friendly thing that will stop them from wasting with, with javascript, but you should also add something more secure (javascript can be gotten around) serverside to check the file then as well.
    Daniel - Freelance Web Design | <?php?> | <html>| español | Deutsch | italiano | português | català | un peu de français | some knowledge of several other languages: I can sometimes help translate here on DD | Linguistics Forum

  6. #6
    Join Date
    Jun 2005
    Location
    英国
    Posts
    11,876
    Thanks
    1
    Thanked 180 Times in 172 Posts
    Blog Entries
    2

    Default

    Twey

    NO SERVER_SIDE VALIDATION...
    Then you're wasting your time. Why can you not use server-side validation? As djr33 says, you must already be using a server-side script, or your form won't do anything
    he has options only to select a file and on uploading [clicking the button] it has to check whether a file is been selected.
    There's not really much you can do. The file input is a rather unstandardised element, and although it usually manifests itself as the popular textbox and button, it doesn't have to according to the standards. It offers virtually no control over itself.
    Twey | I understand English | 日本語が分かります | mi jimpe fi le jbobau | mi esperanton komprenas | je comprends français | entiendo español | tôi ít hiểu tiếng Việt | ich verstehe ein bisschen Deutsch | beware XHTML | common coding mistakes | tutorials | various stuff | argh PHP!

  7. #7
    Join Date
    Mar 2006
    Location
    Illinois, USA
    Posts
    12,164
    Thanks
    265
    Thanked 690 Times in 678 Posts

    Default

    Plus, you won't have access to the person's computer to check if the file does exist... so... yeah.


    And, again, don't you want secure? The only way IS server side.
    Daniel - Freelance Web Design | <?php?> | <html>| español | Deutsch | italiano | português | català | un peu de français | some knowledge of several other languages: I can sometimes help translate here on DD | Linguistics Forum

  8. #8
    Join Date
    Jun 2006
    Posts
    182
    Thanks
    0
    Thanked 14 Times in 14 Posts

    Default

    Well, actually there is a "tricky" way to style file inputs.
    Check out this: http://www.quirksmode.org/dom/inputfile.html

  9. #9
    Join Date
    Jun 2005
    Location
    英国
    Posts
    11,876
    Thanks
    1
    Thanked 180 Times in 172 Posts
    Blog Entries
    2

    Default

    Ah, clever
    Twey | I understand English | 日本語が分かります | mi jimpe fi le jbobau | mi esperanton komprenas | je comprends français | entiendo español | tôi ít hiểu tiếng Việt | ich verstehe ein bisschen Deutsch | beware XHTML | common coding mistakes | tutorials | various stuff | argh PHP!

  10. #10
    Join Date
    Jun 2006
    Posts
    6
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Thanks all 4 posting and solving my issues and thanks for DimX who show the styles of input type file.

    PraDz

Bookmarks

Posting Permissions

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