Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

onBlur coldfusion validate

Posted on 2010-11-15
6
Medium Priority
?
737 Views
Last Modified: 2012-05-10
I have a text field that is entered (18 characters max). and I want to make sure this value does not
already exist on a table. Instead of validating after a submit, I would like to validate after entry is made,...
so onBlur.

I am trying to figure out how to write the function to make cfquery. If exists, error that need to re-enter new
value. I have done 'static' data checks but not a cfquery.

I am on CF 9
0
Comment
Question by:mahpog
  • 3
  • 3
6 Comments
 
LVL 29

Expert Comment

by:Pravin Asar
ID: 34145486
Use  <CFDIV> tag  for AJAX call.

e.g.


<cfform name="form1">
YOUR INPUT FIELD:<cfinput name="stext1" type="text" >
</cfform>

<!--- CFDIV --->

<cfdiv bindonload="false"  bind="url:CheckInput.cfm?idt={stext1@blur}" ID="theDiv"
        style="background-color:##CCffFF; color:red; height:100"/>




For testing purpose use the following cfm file.

<!-- CheckInput.CFM --->

<cfdump var="#url#">
0
 

Author Comment

by:mahpog
ID: 34146734
I am attaching what happened. Anyone else with suggestions. i went to Adobe CF 9 Reference with 'same' (not quite) example.  I need more help.  

thx.
example.pdf
0
 

Author Comment

by:mahpog
ID: 34146828
Okay, I had a typo. and it is responding with "no record", or dump. But if the record exists, I want the user to re-enter a another number. If the record does not exist, then allow the entry and go to next field.
0
Keep up with what's happening at Experts Exchange!

Sign up to receive Decoded, a new monthly digest with product updates, feature release info, continuing education opportunities, and more.

 
LVL 29

Expert Comment

by:Pravin Asar
ID: 34147606
1. Usage of cfdebug

    Add to your page which is holds cfdiv tag

       e.g. :   http://localhost/mypage.cfm?cfdebug


When ever any AJAX requests are posted, the debug window is updated.

2. You many not have to pass session variable. It is available across all requests/cfm pages.

0
 
LVL 29

Accepted Solution

by:
Pravin Asar earned 1500 total points
ID: 34147751
Here is better checkinput.cfm

<!---<cfdump var="#url#">--->

<cfset reclist="1,3,5">
<cfset found=false>
<cfloop index="ix" from="1" to="#ListLen(reclist)#">
<cfif ListGetAt(reclist,ix) eq #url.stext1#>
<cfset found=true/>
<cfbreak/>
</cfif>
</cfloop>
<cfoutput>
<cfif #found#>
<script type="text/javascript">
document.form1.stext1.value='RECORD EXISTS, Enter Another Number';
</script>
<cfelse>
<h2>RECORD DOES NOT EXISTS</h2>
</cfif>
</cfoutput>


The main page is unchanged.



<cfform name="form1">
<br/>TEXT:<cfinput name="stext1" type="text" >
</cfform>
<cfdiv bindonload="false"   bind="url:CheckInput.cfm?stext1={stext1@blur}" ID="theDiv"
        style="background-color:##CCffFF; color:red; height:100"/>

0
 

Author Closing Comment

by:mahpog
ID: 34149453
I did learn how to make my syntax work properly.
0

Featured Post

New feature and membership benefit!

New feature! Upgrade and increase expert visibility of your issues with Priority Questions.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

The technique is by far very Simple! How we can export the ColdFusion query results to DOC file?  Well before writing this I researched a lot in Internet but did not found a good Answer anyways!  So i thought now i should share my small snippet w…
Adobe Dreamweaver CS5 is a WYSIWYG web page editor that has advanced HTML, CSS, and Javascript rendering functionality and is probably the most well-known HTML editor available. Much of Dreamweaver's appeal centers around the Design View interfac…
this video summaries big data hadoop online training demo (http://onlineitguru.com/big-data-hadoop-online-training-placement.html) , and covers basics in big data hadoop .
When cloud platforms entered the scene, users and companies jumped on board to take advantage of the many benefits, like the ability to work and connect with company information from various locations. What many didn't foresee was the increased risk…

772 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question