Skip to main content
Participant
May 5, 2008
Question

CFSelect Change required attribute based on user input

I would like to upload text to a db and give users the option to upload associated files on the same form. If they choose to upload a file by using the cffile tag file selector (file1), I need to require them to select a file type from a cfselect tag (type1) to route the file to its proper desitination of the server. The problem is that if I make the type1 field required, I can't submit the form without selecting a type even though their is no file to upload. If type1 isn't required, the file won't be uploaded to the proper directory.

My thought is to make the type1 field required only if a file is selected by the user using the onchange attribute. How can I do this? or is their a better way still using client-side validation?

Thanks for your help.
    This topic is closed to new replies. Start a new post to keep the conversation going.

    4 replies

    2old2noAuthor
    Participant
    May 6, 2008
    Thanks
    Translate
    Inspiring
    May 5, 2008
    I can personally vouch for the book, Teach Yourself Javascript in 24 Hours by SAMS publishing. It's how I learned.
    Translate
    2old2noAuthor
    Participant
    May 5, 2008
    I'm a beginner at js.
    Translate
    Inspiring
    May 5, 2008
    How's your javascript?
    Translate