Solved

onBlur coldfusion validate

Posted on 2010-11-15
6
662 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 28

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
Free Trending Threat Insights Every Day

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

 
LVL 28

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 28

Accepted Solution

by:
Pravin Asar earned 500 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

Highfive Gives IT Their Time Back

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Suggested Solutions

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…
Hi, Even though I have created this Tutorial on My personal Blog, Some people might not able to find my website, So here i am posting it again Today, from the topic it is very clear that i will be showing you here the very basic usage of how we …
It is a freely distributed piece of software for such tasks as photo retouching, image composition and image authoring. It works on many operating systems, in many languages.
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…

760 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

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now