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 xmlns="">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>

<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">

Thank you!

Recommended Answers

All 2 Replies

You need to use a javascript function for this:

function ChangeButtonStatus()
    if (document.getElementById("Text").value.length > 0)
      document.getElementById("submit").disabled = false;
      document.getElementById("submit").disabled = true;

Then in your form, add an OnBlur event to the textbox:

<cfinput type="text" name="Text" id="Text" OnBlur="ChangeButtonStatus()">

cmhamton has provided the solution - but just to expand:
So as to open the function to any form and any form objects:

function toggleObj(frmFld,frmBtn) 
//frmFld = the Form Field to check for value
//frmBtn = the Form Button to disable/enable


sorry - haven't actually tested this...

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.