Solved

onBlur coldfusion validate

Posted on 2010-11-15
6
668 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
3 Use Cases for Connected Systems

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, testing some more, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us.

 
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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

PROBLEM: How to add your own buttons to the bottom toolbar with paging info ( result count ). While creating a cfgrid, I ran into an issue where I wanted to embed my own custom buttons where the default ones ( insert / delete / etc… ) are for aes…
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 …
Internet Business Fax to Email Made Easy - With  eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, f…
With the power of JIRA, there's an unlimited number of ways you can customize it, use it and benefit from it. With that in mind, there's bound to be things that I wasn't able to cover in this course. With this summary we'll look at some places to go…

867 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

18 Experts available now in Live!

Get 1:1 Help Now