| | |
Automate undisabled a “submit button”?
Please support our ColdFusion advertiser: PostgreSQL or MySQL? Compare and contrast the two most popular open source databases
Thread Solved |
•
•
Join Date: Mar 2008
Posts: 5
Reputation:
Solved Threads: 0
Help!
Hi, everbody!
I have this problem:
There is a “textbox” and a “submit” button.
“Submit button” is disabled until something is written within “text box”. I am not able to do this switch. Could anybody help me?
Here you are the code:
Thank you!
Hi, everbody!
I have this problem:
There is a “textbox” and a “submit” button.
“Submit button” is disabled until something is written within “text box”. I am not able to do this switch. Could anybody help me?
Here you are the code:
html Syntax (Toggle Plain Text)
<html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>Untitled Document</title> </head> <body> <cfform name="form1" id="form1" method="post" action=""> <cfinput type="text" name="Text" id="Text"> <cfinput type="submit" name="submit" disabled="disabled" id="submit" value="Submit"> </cfform> </body> </html>
Last edited by peter_budo; Apr 7th, 2008 at 8:01 pm. Reason: Keep It Organized - please use [code] tags
You need to use a javascript function for this:
Then in your form, add an OnBlur event to the textbox:
Javascript Syntax (Toggle Plain Text)
function ChangeButtonStatus() { if (document.getElementById("Text").value.length > 0) { document.getElementById("submit").disabled = false; } else { document.getElementById("submit").disabled = true; } }
Then in your form, add an OnBlur event to the textbox:
ColdFusion Syntax (Toggle Plain Text)
<cfinput type="text" name="Text" id="Text" OnBlur="ChangeButtonStatus()">
•
•
Join Date: Oct 2005
Posts: 8
Reputation:
Solved Threads: 1
cmhamton has provided the solution - but just to expand:
So as to open the function to any form and any form objects:
sorry - haven't actually tested this...
So as to open the function to any form and any form objects:
ColdFusion Syntax (Toggle Plain Text)
function toggleObj(frmFld,frmBtn) { //frmFld = the Form Field to check for value //frmBtn = the Form Button to disable/enable if(frmFld.value.length>0) { frmBtn.disabled=false; } else { frmBtn.disabled=true; } }
sorry - haven't actually tested this...
![]() |
Other Threads in the ColdFusion Forum
- Previous Thread: hash() md5 and url encoding issue
- Next Thread: Where to purchase
Views: 2663 | Replies: 2
| Thread Tools | Search this Thread |
Tag cloud for ColdFusion





