JavaScript questions

Discussion in 'OT Technology' started by GotVtec, Jan 30, 2004.

  1. GotVtec

    GotVtec 8th World Wonder

    Joined:
    Mar 14, 2000
    Messages:
    575
    Likes Received:
    0
    Location:
    Omaha, NE
    ...actually two off them.

    1. I am looking for a some javascript that can validate what type of file you are trying to upload, so a user can only upload files with a .doc extensions

    2. How do I make my submit button grey or unclick able until the entire form is filled our correctly?

    Thanks!
     
  2. Astro

    Astro Code Monkey

    Joined:
    Mar 18, 2000
    Messages:
    2,047
    Likes Received:
    0
    Location:
    Cleveland Ohio
    1. You must do it server side. Sucks to be the user that uploaded the wrong one. But such is life. The browser does not give JavaScript access to the file input box. The best you could probably do is provide another input widget that asks the user what file format they are uploading. Although clueless users will probably get this wrong too. If you're able to do some server side scripting, then you can somewhat easily ID the file based on the content. Good example, I'm working a script right now that can determine if its an Excel file or a csv file based on the first character in the file. Its not bullet proof, but I think more so then the extension.

    2. There's the ability to enable and disable form elements. This used to be an IE only trick, but I think Mozilla now supports it too. But watch out, other browsers may not. Sadly, I don't know the property you need to toggle. I'd recommend consulting google.
     

Share This Page