digitalwise
asked on
Disable Submit Button on CFC cfdiv bind
We are checking to see if the email address is already in the system. If it is, the system displays the message that the email is in the system but does not clear the email address. I want to disable the submit button until they enter a valid email. Any suggestions?? I am open to clearing the field too but every time I try that, the message goes away.
CFC
<TR class="special"><TD valign="top"><img src="images/RedStar.gif" ALT="Required" /></TD><TD class="tdheader" valign="top">Email:</TD><TD><cfinput type="text" name="email" size="40" Required="yes" message="Please enter an email for this person - check the formatting." value="#getemail.emailaddress#" maxlength="50" validate="email">
<cfdiv bind="cfc:email.checkemail({email})"
style="font-size:14px; color:blue;" />
</TD></TR>
CFC
<cffunction name="checkemail" access="remote" returnType="string">
<cfargument name="email" type="string" required="true">
<!--- Define variables --->
<cfset var data="">
<cfset var result="">
<!--- Get data --->
<CFQUERY NAME="CheckEmail" datasource="appa_backoffice">
select contactinfoid from cn_emailaddresses where emailaddress = '#arguments.email#'
</CFQUERY>
<!--- Got it? --->
<cfif CheckEmail.RecordCount gt 0 and len(arguments.email)>
<cfset result="<br><em><span style='color: red;'>The email you have entered is already in the database. Please enter a different email address.</span></em>">
<CFELSE>
<CFSET result="">
</cfif>
<!--- And return it --->
<cfreturn result>
</cffunction>
Hello,
I am not sure, if you still interested in the solution.
Anyway here is a simple coldfusion bind example.
<!--- example.cfm --->
<cfform name="f0">
<cfinput name="email" value="" type="text"/>
<!--- Look for keyup on email field ---->
<cfdiv bindonload="true" bind="url:ajaxRes.cfm?fiel d={email@k eyup}" style="font-size: 14px;">
</cfdiv>
</cfform>
<!---- ajaxRes.cfm --->
<cfif isdefined ("url.field") and len(trim(url.field))>
<input type="submit" value="Submit" name="sbtn1"/>
<cfelse>
<cfoutput>Enter field value</cfoutput>
</cfif>
I am not sure, if you still interested in the solution.
Anyway here is a simple coldfusion bind example.
<!--- example.cfm --->
<cfform name="f0">
<cfinput name="email" value="" type="text"/>
<!--- Look for keyup on email field ---->
<cfdiv bindonload="true" bind="url:ajaxRes.cfm?fiel
</cfdiv>
</cfform>
<!---- ajaxRes.cfm --->
<cfif isdefined ("url.field") and len(trim(url.field))>
<input type="submit" value="Submit" name="sbtn1"/>
<cfelse>
<cfoutput>Enter field value</cfoutput>
</cfif>
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Thanks as usual!
So I think, you will be better of enable/disable the button , you could simply use jquery/javascript solution.
Here is some sample code.
<cfform name="f0">
<cfinput type="text" name="email" onkeyup="validate()"/>
<cfinput type="submit" name="sbtn1" value="Submit" disabled="true" />
</cfform>
<script type="text/javascript">
function validate(){
alert (document.f0.email.value.l
if (document.f0.email.value.l
document.f0.sbtn1.removeAt
}
else {
document.f0.sbtn1.setAttri
}
}
</script>