cfajaxproxy data validation

PhotoMan2000
PhotoMan2000 used Ask the Experts™
on
I'm new at the cfajaxproxy.. and need some help getting a validation to work.
I want to be able to have a textbox validate ONBLUR a phone number (check to see if it is already in a database)

What I see happening is as the user moves through a form and exits out of the textbox for the phone number, the data is checked against a database and an error message pops up saying that the numer is already registerted, or the jquery will handle the erros messaging including the lenght of the input data for proper digits.

Below is the from, my cfc and some jquery code for display validation.


<cfcomponent>
	<cffunction name="checkRegPhone" access="public" returntype="string">
		<cfargument name="myArgument" type="string" required="yes">
		  <cfquery datasource="#application.wlcnDsn#" name="checkExistingReg">
			SELECT phone
            FROM vents
            WHERE phone = #url.phone#
            Limit 1
	</cfquery>
		<cfreturn myResult>
	</cffunction>
</cfcomponent>
======================
<script type="text/javascript" src="../../../../scripts/prototype.1.6.3.js"></script>
<script type="text/javascript" src="../../../../scripts/jquery-1.3.2.js" ></script>
<cfset test4futurVar = '2065552'>
<cfset regPhoneNumb = StructNew()>
<script>
  $(document).ready(function()
	{
  	$("#wlcnReg").validate(
		{
		rules: {
			phone: {required: true, number: true, minlength: 10, maxlength: 10}
			},
		messages:{
			phone: "Please enter your full phone number (5555551212)"
			}			
	});	
  });
</script>
<cfajaxproxy cfc="checkRegPhone.cfc">  
<cfform name="09Reg" id="Reg"  method="post" preservedata="yes" action="thankyou.cfm">  
   <cfinput type="text" name="phone" id="phone" maxlength="10" onBlur="" />
   <cfinput type="submit" name="button2" id="button2" value="Submit" />
</cfform>

Open in new window

Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
where you have
<cfajaxproxy cfc="checkRegPhone.cfc">  
you'd need to change to
<cfajaxproxy cfc="checkRegPhone">  
but also does your app know the path to your checkRegPhone file?
for example it may be located in a folder named cfcs in root dir so you'd then code it as
<cfajaxproxy cfc="cfcs.checkRegPhone">
I have no big objection, but do feel that if you believe the solution I provided "is probably correct" then it may have been fair to award points.

Author

Commented:
I thought I did.. Admin - please award points.
Well thank you!
I believe you need to click the accept as answer link and possibly cancel the delete request.
Not sure as I've never done it though.

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial