I am trying to write a script to ch开发者_运维问答eck the availability of the passed username and email address, using ExtJs or JQuery; and Coldfusion 9 as server language. I have written one script but it's not working as intented.
Thanks Vicente
Something like this:
<cfcomponent hint="services.userService">
<cffunction name="checkUser" access="remote" returnformat="json" returntype="struct">
<cfargument name="username">
<cfargument name="email">
<cfset var result = { 'usernameExists' = true, 'emailExists' = true }>
<!--- TODO: Check if the UN and Password exist --->
<cfreturn result>
</cffunction>
</cfcomponent>
Then:
<script>
$.getJSON("services/userService.cfc?method=checkUser",
{ username = theUsername, email = theEmail },
function(json) {
if (json.usernameExists) { ... }
if (json.emailExists) { ... }
}
);
</script>
This page has an easy example of checking username validity and availability along witha tutorial and explanation.
http://jqueryfordesigners.com/using-ajax-to-validate-forms/
精彩评论