General discussion


Button to appear

By jprince245 ·

I am trying to create a form using HTML and ColdFusion, where the submit button is hidden until all required fields entered. Is it possible to do this using ColdFusion or Javascript?

Thank you in advance

This conversation is currently closed to new comments.

2 total posts (Page 1 of 1)  
| Thread display: Collapse - | Expand +

All Comments

Collapse -

use Javascript

by Jay Eckles In reply to Button to appear

You'll want to use Javascript for this. When the page is loaded, use Javascript to hide the button (this way, if the user doesn't have Javascript enabled, he or she can still submit the form). When the user enters data in a required field, it willtrigger the onChange event. My first thought is to call the same function for each adds one to a static variable that is initialized to 0 when the page loads. Then it checks to see if the value of the variable is equal to the number of required fields. If so, it unhides the submit button. You'll want to add some logic to decrement the variable if the user deletes from a required field and to not increment the variable again if the user just changes the value of a required field from x to y.

Good luck.


Collapse -

input type

by jprince245 In reply to use Javascript

I tried using Javascript to change the input type from hidden to submit but this produced errors stating something like type is not a valid property. I also tried to place script in the body where the button would appear and have a function execute this script once all required fields had values. The button appeared after clearing the page. My Javascript to write in the button was
document.write('<input type="submit" name="submit" value="Submit">'
I am still in the process of learning Javascript so my understanding of it is pretty limited.

Back to Web Development Forum
2 total posts (Page 1 of 1)  

Related Discussions

Related Forums