Re: [jQuery] Calling all CF'ers... et al...

2007-03-15 Thread Klaus Hartl
Jörn Zaefferer schrieb:
 Klaus Hartl schrieb:
 Yes, that is already useful! But it still depends on the form to be 
 submitted. Would be cool to have single fields validated on blur. That 
 would of course be useful for client-side validation as well. Maybe its 
 already implemented? I'm not uptodate with that.
   
 Currently you can specify one additional event for validation on each 
 element.
 
 I guess the combination of pure-client-side validation on keyup and 
 submit with ajax-validation on blur would be the killer.
 
 I'll investigate that.

That would be what we call in German eierlegende Wollmilchsau.

I wonder whats the equivalent in english is! LEO says: all-in-one 
device suitable for every purpose. Sorry, thats much funnier in German!

:-)



-- Klaus

___
jQuery mailing list
discuss@jquery.com
http://jquery.com/discuss/


Re: [jQuery] Calling all CF'ers... et al...

2007-03-14 Thread Priest, James \(NIH/NIEHS\) [C]
Heh - I've been riding motorcycles for ages with no mishaps - 2 weeks
ago I'm riding bikes with my daughter and take a header into the street
- tore up my shoulder a bit.  Bicycles are dangerous :)

I'm in the same boat - very little JS/Ajax experience.  I need to wrap
this project up so don't have any time to even try to implement this but
I'm certainly going to look at it for the next project - along with all
the other cool stuff that keeps popping up on the list :)  I can't keep
up!

Jim

 

 -Original Message-
 From: Rick Faircloth [mailto:[EMAIL PROTECTED] 
 Sent: Tuesday, March 13, 2007 9:16 AM
 To: 'jQuery Discussion.'
 Subject: Re: [jQuery] Calling all CF'ers... et al...
 
 Hi, Jim...
 
 I'm glad you've got some weather to enjoy your motorcycle.
 I'm not the kind of cyclist... I'm talking about a road bicycle.
 Trying to keep in shape as I get older!  ;o)
 
 Anyone... no, not using any kind of framework...sorry.
 
 Are you using CF for all your validation processing?  It seems
 like that would be a very flexible way to proceed.  As Paul
 is doing in his example, we can run queries against the input,
 check for being numerical, etc.
 
 I've developed some pretty good CF techniques for validation,
 but they always involved submitted an entire form first.  I'd like
 to get down to onblur field after field validation.  I've just never
 used much js and no ajax before...
 
 Rick
 
 -Original Message-
 From: [EMAIL PROTECTED] 
 [mailto:[EMAIL PROTECTED] On
 Behalf Of Priest, James (NIH/NIEHS) [C]
 Sent: Tuesday, March 13, 2007 8:52 AM
 To: jQuery Discussion.
 Subject: Re: [jQuery] Calling all CF'ers... et al...
 
 Completely off topic but I rode into work today as well 
 (motorcyclist)!
 A bit chilly this AM (40) but supposed to be in the low 80's!  Might
 have to leave early :)
 
 On a more CF related note - are you using any kind of framework with
 this validation technique?  Just curious... I'm working on my first
 Mach-II application and have a validation filter setup and am 
 trying to
 figure out how I could implement something like this...
 
 Jim 
 
  -Original Message-
  From: Paul [mailto:[EMAIL PROTECTED] 
  Sent: Monday, March 12, 2007 7:08 PM
  To: 'jQuery Discussion.'
  Subject: Re: [jQuery] Calling all CF'ers... et al...
  
  Rick, I'll see if I can make time for this tonight...  It's 
  65 outside and
  my road bike beckons seductively from the garage.  
  Unfortunately my desire
 
 ___
 jQuery mailing list
 discuss@jquery.com
 http://jquery.com/discuss/
 
 
 
 ___
 jQuery mailing list
 discuss@jquery.com
 http://jquery.com/discuss/
 

___
jQuery mailing list
discuss@jquery.com
http://jquery.com/discuss/


Re: [jQuery] Calling all CF'ers... et al...

2007-03-14 Thread Rick Faircloth
 I'm riding bikes with my daughter and take a header into the street

Stay away from the curbs!  That was what caused my first fall.
Only had two in 15,000 miles and 6 years of riding!  No telling
how many times I fell on my motorcycle...but that was when I was
14 and falling off was 1/2 the fun!  (Not so much fun at 46! :o)

I know what you mean about the possibilities for jQuery.  I keep
marking too many good ideas I want to implement.  I have to keep
working and implementing this a little at a time!

Rick

-Original Message-
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On
Behalf Of Priest, James (NIH/NIEHS) [C]
Sent: Wednesday, March 14, 2007 8:15 AM
To: jQuery Discussion.
Subject: Re: [jQuery] Calling all CF'ers... et al...

Heh - I've been riding motorcycles for ages with no mishaps - 2 weeks
ago I'm riding bikes with my daughter and take a header into the street
- tore up my shoulder a bit.  Bicycles are dangerous :)

I'm in the same boat - very little JS/Ajax experience.  I need to wrap
this project up so don't have any time to even try to implement this but
I'm certainly going to look at it for the next project - along with all
the other cool stuff that keeps popping up on the list :)  I can't keep
up!

Jim

 




___
jQuery mailing list
discuss@jquery.com
http://jquery.com/discuss/


Re: [jQuery] Calling all CF'ers... et al...

2007-03-13 Thread Priest, James \(NIH/NIEHS\) [C]
Completely off topic but I rode into work today as well (motorcyclist)!
A bit chilly this AM (40) but supposed to be in the low 80's!  Might
have to leave early :)

On a more CF related note - are you using any kind of framework with
this validation technique?  Just curious... I'm working on my first
Mach-II application and have a validation filter setup and am trying to
figure out how I could implement something like this...

Jim 

 -Original Message-
 From: Paul [mailto:[EMAIL PROTECTED] 
 Sent: Monday, March 12, 2007 7:08 PM
 To: 'jQuery Discussion.'
 Subject: Re: [jQuery] Calling all CF'ers... et al...
 
 Rick, I'll see if I can make time for this tonight...  It's 
 65 outside and
 my road bike beckons seductively from the garage.  
 Unfortunately my desire

___
jQuery mailing list
discuss@jquery.com
http://jquery.com/discuss/


Re: [jQuery] Calling all CF'ers... et al...

2007-03-13 Thread Klaus Hartl
Jörn Zaefferer schrieb:
 Klaus Hartl schrieb:
 Paul schrieb:
   
 What you described is basically what I do, Rick--not because Jorn's plugin
 didn't work but because many of my form fields are validated against each
 other, and database interaction is required to make that decision. (e.g.,
 the validity of field Y depends on the value already entered in field X.)

 Below is the validate function I call onBlur from each input.  It first sets
 the field's status icon to a loading spinny, then requests validation from a
 CFM file, passing the value of the current field as well as the value of the
 dependent criteria, which CF handles (cfswitch/cfcase) depending on which
 field is passed.  The callback receives the response and shows either a
 success or error icon with a descriptive error attached in a stylish little
 error message balloon.

 I don't know if this is the smartest method--I'm pretty new to jQuery
 myself--but it has worked very well and provides the flexibility I need.

 HTH,
 Paul
 
 The good thing about such an approach is, that you have to implement 
 server-side validation anyway - client-side validation can never be more 
 than an addon to enhance user experience unless you can rely on 
 JavaScript being enabled. So why not reuse that logic client-side as 
 well for single fields. You improve the user experience while all logic 
 is still in place.
   
 One of the long-term targets of the validation plugin is to generate as 
 much of the client-side validation rules as possible based on the 
 serverside rules, without additional ajax requests.
 
 Until that is available in any form, you could use the validation plugin 
 to display your messages (returned from your AJAX request).
 
 See this demo: 
 http://jquery.bassistance.de/validate/demo-test/ajaxSubmit-intergration-demo.html
 
 The relevant client code is this:
 
 var v = $(#form).validate({
   submitHandler: function(form) {
   $(form).ajaxSubmit({
   dataType: json,
   after: function(result) {
   if(result.status) {
   v.showErrors(result.data);
   }   
   }
   });
   }
 });
 
 In that example, result.data looks like this:
 
 {'password': 'Your password is wrong (must be foobar).'}
 
 That way you can use the same setup for displaying both clientside and 
 serverside validation errors. Useful?
 

Yes, that is already useful! But it still depends on the form to be 
submitted. Would be cool to have single fields validated on blur. That 
would of course be useful for client-side validation as well. Maybe its 
already implemented? I'm not uptodate with that.

-- Klaus


___
jQuery mailing list
discuss@jquery.com
http://jquery.com/discuss/


Re: [jQuery] Calling all CF'ers... et al...

2007-03-13 Thread Klaus Hartl
Paul schrieb:
 It would normally be smart, Klaus, but in my case not much would be gained.
 I'm building an intranet app, and at 100 mps the ajax calls come back
 extremely quickly.  (truthfully I've yet to see my spinny graphic show
 up...)

So why wouldn't there be gained much? You could still have the 
validation logic in one place, the server. My concerns were not so much 
about speed, but about maintenance. And by the way, the faster the 
connection is, the more you'll benefit from a client-side validation 
done on the server, as the seam becomes unnoticable.


-- Klaus

___
jQuery mailing list
discuss@jquery.com
http://jquery.com/discuss/


Re: [jQuery] Calling all CF'ers... et al...

2007-03-13 Thread Rick Faircloth
Hi, Jim...

I'm glad you've got some weather to enjoy your motorcycle.
I'm not the kind of cyclist... I'm talking about a road bicycle.
Trying to keep in shape as I get older!  ;o)

Anyone... no, not using any kind of framework...sorry.

Are you using CF for all your validation processing?  It seems
like that would be a very flexible way to proceed.  As Paul
is doing in his example, we can run queries against the input,
check for being numerical, etc.

I've developed some pretty good CF techniques for validation,
but they always involved submitted an entire form first.  I'd like
to get down to onblur field after field validation.  I've just never
used much js and no ajax before...

Rick

-Original Message-
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On
Behalf Of Priest, James (NIH/NIEHS) [C]
Sent: Tuesday, March 13, 2007 8:52 AM
To: jQuery Discussion.
Subject: Re: [jQuery] Calling all CF'ers... et al...

Completely off topic but I rode into work today as well (motorcyclist)!
A bit chilly this AM (40) but supposed to be in the low 80's!  Might
have to leave early :)

On a more CF related note - are you using any kind of framework with
this validation technique?  Just curious... I'm working on my first
Mach-II application and have a validation filter setup and am trying to
figure out how I could implement something like this...

Jim 

 -Original Message-
 From: Paul [mailto:[EMAIL PROTECTED] 
 Sent: Monday, March 12, 2007 7:08 PM
 To: 'jQuery Discussion.'
 Subject: Re: [jQuery] Calling all CF'ers... et al...
 
 Rick, I'll see if I can make time for this tonight...  It's 
 65 outside and
 my road bike beckons seductively from the garage.  
 Unfortunately my desire

___
jQuery mailing list
discuss@jquery.com
http://jquery.com/discuss/



___
jQuery mailing list
discuss@jquery.com
http://jquery.com/discuss/


Re: [jQuery] Calling all CF'ers... et al...

2007-03-13 Thread Rick Faircloth
Hi, Paul...

Enjoy your ride yesterday?

Thanks for the example code... it's beginning to make some sense
as I study it.

However, there one key sticking point... I'm using CF 4.5, so I don't
use .cfc's that you asked about when your referenced
cfoutput#json.encode(st)#/cfoutput
and the json.cfc.

Is there another method to pass the result back to the calling page?

Can I use the same method I used in my previous attempt at validation
the submitHandler function? (I guess that's what was responsible for
sending
the data to and from my MortgageCalucation.cfm page...)

Here's that function...

submitHandler:function(){

varParams={};
$(input:text).each(function(){
Params[$(this).attr(name)]=$(this).val();
})

$.post(Mortgage_Calculation.cfm,Params,function(data){
$(#Result).empty().append(data);
})

}


Rick

-Original Message-
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On
Behalf Of Paul
Sent: Monday, March 12, 2007 11:26 PM
To: 'jQuery Discussion.'
Subject: Re: [jQuery] Calling all CF'ers... et al...

Okay as promised Will, here's what I do.  It's most certainly not the most
efficient method, since it's my first go 'round, but it does what I ask it
to.  I've added a few comments inline for you.  (After pasting in here I
can't even tell what's going on--and I wrote it!  Paste this into your
editor to get a clearer view...) 

A) Here is a snippet of the original html.  It simply presents a
field/label.

div class=row id=shipto_location
div class=requiredShip-to location:/div input type=text
maxlength=75 !--- these inputs are all autocomplete text fields ---
img src= width=14 height=14 class=ico  !--- call $(.row
img).hide() on page load ---
/div

B) Here is the jQuery bit that binds a behavior to the blur event.  In my
case this comes from a Taconite response, but I think you'd need it in your
document.ready() function for testing.  

$(#shipto_location input).blur(function (){
/* when the input within #shipto_location loses focus, pass the name
of the input and the value of the customer name input to be validated */
validateField('shipto_location',$(#customer_name input).val());
});

C) As posted before, here is the validateField function called by part B
above.

function validateField(field, criteria){
/* change the src of the row's icon (in this example,
#shipto_location img.ico) to the loading spinny */
$(#+field+
img.ico).attr(src,/images/office/ico-loading.gif);
/* pass the name of the field to validate, the value of said field,
and the value of an optional criteria (in this case, $(#customer_name
input).val()) */
$.get(/gateway/validate.cfm?field=+field+value=+$(#+field+
input).val()+criteria=+criteria,
function(response){
/* evaluate the json response */
response = eval((+response+));
/* display the appropriate icon; showIcon
can be called after either ajax or local validation */
showIcon(field,response.pass,response.msg);
}); 
}

D) Here's the relevant snippet from validate.cfm:

!--- the cfswitch expression is url.field ---
cfcase value=shipto_location delimiters=|
cfquery name=q datasource=Yard
select s.shipto_id
from  shipto_locations as s inner join
  customers as c on s.customer_id = c.customer_id
where (s.shipto = cfqueryparam value=#url.value#) and
(c.customer = cfqueryparam value=#url.criteria#)
/cfquery
cfif q.recordcount GT 0
!--- The value of st[pass] is set to false by default
above the cfswitch block ---
cfset st[pass]=true
cfelse
cfset st[msg]='#url.value#' is not a valid
#url.criteria# location.
/cfif
/cfcase
...
!--- after the cfswitch expression, display the struct in json format (you
have json.cfc, right?) ---
cfoutput#json.encode(st)#/cfoutput





___
jQuery mailing list
discuss@jquery.com
http://jquery.com/discuss/


Re: [jQuery] Calling all CF'ers... et al...

2007-03-13 Thread Jörn Zaefferer
Klaus Hartl schrieb:
 Yes, that is already useful! But it still depends on the form to be 
 submitted. Would be cool to have single fields validated on blur. That 
 would of course be useful for client-side validation as well. Maybe its 
 already implemented? I'm not uptodate with that.
   
Currently you can specify one additional event for validation on each 
element.

I guess the combination of pure-client-side validation on keyup and 
submit with ajax-validation on blur would be the killer.

I'll investigate that.

-- 
Jörn Zaefferer

http://bassistance.de


___
jQuery mailing list
discuss@jquery.com
http://jquery.com/discuss/


Re: [jQuery] Calling all CF'ers... et al...

2007-03-13 Thread Paul
Wow, CF 4.5?  That's the version I learned on--you're really old school!
I'm not sure the best way to implement what json.cfc does without the
cfc--or even without user defined functions which came around in version
5.0--but you can look at it and maybe just pull the functionality you need
out of the cfc -- http://www.epiphantastic.com/cfjson/.  

I don't know about that submitHandler function--as I said I'm new to jQuery
and it doesn't look like what I've done in the past, but it may be another
route to consider...

My bike ride was great, thanks, as was 27 holes of golf today.  How is one
supposed to work during such beautiful spring weather?? 

-Original Message-
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On
Behalf Of Rick Faircloth
Sent: Tuesday, March 13, 2007 10:00 AM
To: 'jQuery Discussion.'
Subject: Re: [jQuery] Calling all CF'ers... et al...

Hi, Paul...

Enjoy your ride yesterday?

Thanks for the example code... it's beginning to make some sense
as I study it.

However, there one key sticking point... I'm using CF 4.5, so I don't
use .cfc's that you asked about when your referenced
cfoutput#json.encode(st)#/cfoutput
and the json.cfc.

Is there another method to pass the result back to the calling page?

Can I use the same method I used in my previous attempt at validation
the submitHandler function? (I guess that's what was responsible for
sending
the data to and from my MortgageCalucation.cfm page...)

Here's that function...

submitHandler:function(){

varParams={};
$(input:text).each(function(){
Params[$(this).attr(name)]=$(this).val();
})

$.post(Mortgage_Calculation.cfm,Params,function(data){
$(#Result).empty().append(data);
})

}


Rick

-Original Message-
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On
Behalf Of Paul
Sent: Monday, March 12, 2007 11:26 PM
To: 'jQuery Discussion.'
Subject: Re: [jQuery] Calling all CF'ers... et al...

Okay as promised Will, here's what I do.  It's most certainly not the most
efficient method, since it's my first go 'round, but it does what I ask it
to.  I've added a few comments inline for you.  (After pasting in here I
can't even tell what's going on--and I wrote it!  Paste this into your
editor to get a clearer view...) 

A) Here is a snippet of the original html.  It simply presents a
field/label.

div class=row id=shipto_location
div class=requiredShip-to location:/div input type=text
maxlength=75 !--- these inputs are all autocomplete text fields ---
img src= width=14 height=14 class=ico  !--- call $(.row
img).hide() on page load ---
/div

B) Here is the jQuery bit that binds a behavior to the blur event.  In my
case this comes from a Taconite response, but I think you'd need it in your
document.ready() function for testing.  

$(#shipto_location input).blur(function (){
/* when the input within #shipto_location loses focus, pass the name
of the input and the value of the customer name input to be validated */
validateField('shipto_location',$(#customer_name input).val());
});

C) As posted before, here is the validateField function called by part B
above.

function validateField(field, criteria){
/* change the src of the row's icon (in this example,
#shipto_location img.ico) to the loading spinny */
$(#+field+
img.ico).attr(src,/images/office/ico-loading.gif);
/* pass the name of the field to validate, the value of said field,
and the value of an optional criteria (in this case, $(#customer_name
input).val()) */
$.get(/gateway/validate.cfm?field=+field+value=+$(#+field+
input).val()+criteria=+criteria,
function(response){
/* evaluate the json response */
response = eval((+response+));
/* display the appropriate icon; showIcon
can be called after either ajax or local validation */
showIcon(field,response.pass,response.msg);
}); 
}

D) Here's the relevant snippet from validate.cfm:

!--- the cfswitch expression is url.field ---
cfcase value=shipto_location delimiters=|
cfquery name=q datasource=Yard
select s.shipto_id
from  shipto_locations as s inner join
  customers as c on s.customer_id = c.customer_id
where (s.shipto = cfqueryparam value=#url.value#) and
(c.customer = cfqueryparam value=#url.criteria#)
/cfquery
cfif q.recordcount GT 0
!--- The value of st[pass] is set to false by default
above the cfswitch block ---
cfset st[pass]=true
cfelse
cfset st[msg]='#url.value#' is not a valid
#url.criteria# location.
/cfif
/cfcase
...
!--- after the cfswitch expression, display the struct in json format (you
have json.cfc, right

Re: [jQuery] Calling all CF'ers... et al...

2007-03-13 Thread Rick Faircloth
Yeah... CF 4.5 is getting ancient, but she's still kicking!

Your validation example looked good.  Wish I could replicate it.

Glad to hear you enjoyed your ride.  Not a golfer, myself.  (27 holes!)

It's easy to stay off your bike if it's in the shop...mine was in need of
a tune-up a few repairs.  That things got about 15,000 miles on it in the
last 6 years, so some things were getting pretty worn out.

Thanks for your help.  I haven't been able to get anything working, yet,
but I'm still pestering everyone!

Where are you located?

Rick

-Original Message-
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On
Behalf Of Paul
Sent: Tuesday, March 13, 2007 8:36 PM
To: 'jQuery Discussion.'
Subject: Re: [jQuery] Calling all CF'ers... et al...

Wow, CF 4.5?  That's the version I learned on--you're really old school!
I'm not sure the best way to implement what json.cfc does without the
cfc--or even without user defined functions which came around in version
5.0--but you can look at it and maybe just pull the functionality you need
out of the cfc -- http://www.epiphantastic.com/cfjson/.  

I don't know about that submitHandler function--as I said I'm new to jQuery
and it doesn't look like what I've done in the past, but it may be another
route to consider...

My bike ride was great, thanks, as was 27 holes of golf today.  How is one
supposed to work during such beautiful spring weather?? 





___
jQuery mailing list
discuss@jquery.com
http://jquery.com/discuss/


Re: [jQuery] Calling all CF'ers... et al...

2007-03-12 Thread Paul
What you described is basically what I do, Rick--not because Jorn's plugin
didn't work but because many of my form fields are validated against each
other, and database interaction is required to make that decision. (e.g.,
the validity of field Y depends on the value already entered in field X.)

Below is the validate function I call onBlur from each input.  It first sets
the field's status icon to a loading spinny, then requests validation from a
CFM file, passing the value of the current field as well as the value of the
dependent criteria, which CF handles (cfswitch/cfcase) depending on which
field is passed.  The callback receives the response and shows either a
success or error icon with a descriptive error attached in a stylish little
error message balloon.

I don't know if this is the smartest method--I'm pretty new to jQuery
myself--but it has worked very well and provides the flexibility I need.

HTH,
Paul

function validateField(field, criteria){
$(#+field+
img.ico).attr(src,/images/office/ico-loading.gif);
$.get(/gateway/validate.cfm?field=+field+value=+$(#+field+
input).val()+criteria=+criteria,
function(response){
response = eval((+response+));
showIcon(field,response.pass,response.msg);
}); 
}

-Original Message-
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On
Behalf Of Rick Faircloth
Sent: Monday, March 12, 2007 1:55 PM
To: 'jQuery Discussion.'
Subject: [jQuery] Calling all CF'ers... et al...

Hi, guys...

I usually do all my validation using CF, by submitting
a form back to the page it's on, however, I thought I'd
give jQuery a crack at validation.  While it works fine
for the functions that are built-in, they are somewhat limited in function
and I quickly get lost in a lot of code when it comes to custom validation,
such as validating and reformatting dollar values for processing.

What I'm wondering is if I can use jQuery validation, such
as Jorn's Validation plug-in, which I've been working with,
but use calls to CF pages with CF code for validation and
formatting and returning the values to the form.

I've been using Jorn's Validation plug-in, then once all the form
entries are correct, the form values are posted out
with a $.post call to a .cfm page where calculations are run
on the form values, then the result is returned to the calling page.

What I'm getting around to asking is if I can use CF code
on separate pages and have a form field value sent to a
.cfm page onblur for validation using CF code, then have the resulting
value returned to the calling page after processing and/or formatting
and reinserted back into the form field.

I don't know if this makes any sense to anyone.

Let me know if it doesn't and I'll try to clarify.

For example... I use this function to calculate a mortgage payment
once all form values are valid:

function CalculateMortgage(){

var Params = {};

// select all inputs of type text
$(input:text).each(function(){
Params[$(this).attr(name)] = $(this).val();
}); // closes input:text function

// post the form.  The Param object mimics form fields
$.post(Mortgage_Calculation.cfm, Params, function(data){
// this is the processing function.
 
// append what you get back to the element with ID = Result
after clearing its contents
$(#Result).empty().append(data);

} // closes post function
); // closes ( after .post 
} // closes { after CalculateMortgage = function() {


Can I functions that call .cfm pages to process and validate
individual form fields onblur or some other key action?

Rick



___
jQuery mailing list
discuss@jquery.com
http://jquery.com/discuss/


___
jQuery mailing list
discuss@jquery.com
http://jquery.com/discuss/


Re: [jQuery] Calling all CF'ers... et al...

2007-03-12 Thread Daemach

Sure you can.  You can use ajax for anything you want.  

On the currency validation why can't you replace anything that is not a
number or a decimal with  ?  That should give you a valid number to
validate.

validate ele.value.replace(/[^0-9\.]/g,)



Rick Faircloth wrote:
 
 Hi, guys...
 
 I usually do all my validation using CF, by submitting
 a form back to the page it's on, however, I thought I'd
 give jQuery a crack at validation.  While it works fine
 for the functions that are built-in, they are somewhat limited in function
 and I quickly get lost in a lot of code when it comes to custom
 validation,
 such as validating and reformatting dollar values for processing.
 
 What I'm wondering is if I can use jQuery validation, such
 as Jorn's Validation plug-in, which I've been working with,
 but use calls to CF pages with CF code for validation and
 formatting and returning the values to the form.
 
 I've been using Jorn's Validation plug-in, then once all the form
 entries are correct, the form values are posted out
 with a $.post call to a .cfm page where calculations are run
 on the form values, then the result is returned to the calling page.
 
 What I'm getting around to asking is if I can use CF code
 on separate pages and have a form field value sent to a
 .cfm page onblur for validation using CF code, then have the resulting
 value returned to the calling page after processing and/or formatting
 and reinserted back into the form field.
 
 I don't know if this makes any sense to anyone.
 
 Let me know if it doesn't and I'll try to clarify.
 
 For example... I use this function to calculate a mortgage payment
 once all form values are valid:
 
 function CalculateMortgage(){
 
 var Params = {};
 
 // select all inputs of type text
 $(input:text).each(function(){
 Params[$(this).attr(name)] = $(this).val();
 }); // closes input:text function
 
 // post the form.  The Param object mimics form fields
 $.post(Mortgage_Calculation.cfm, Params, function(data){
 // this is the processing function.

 // append what you get back to the element with ID = Result
 after clearing its contents
 $(#Result).empty().append(data);
   
 } // closes post function
 ); // closes ( after .post 
 } // closes { after CalculateMortgage = function() {
 
 
 Can I functions that call .cfm pages to process and validate
 individual form fields onblur or some other key action?
 
 Rick
 
 
 
 ___
 jQuery mailing list
 discuss@jquery.com
 http://jquery.com/discuss/
 
 

-- 
View this message in context: 
http://www.nabble.com/Calling-all-CF%27ers...-et-al...-tf3392261.html#a9444073
Sent from the JQuery mailing list archive at Nabble.com.


___
jQuery mailing list
discuss@jquery.com
http://jquery.com/discuss/


Re: [jQuery] Calling all CF'ers... et al...

2007-03-12 Thread Rick Faircloth
Hi, Paul... it definitely helps right now just to now
the procedure is valid.

Now I've just got to figure out the code.

Now... you say that first you set the field's status to a loading
spinny...

That's done with this line, right?  :

$(#+field+img.ico).attr(src,/images/office/ico-loading.gif);

Next, this line send your form values via url to your .cfm page?:


$.get(/gateway/validate.cfm?field=+field+value=+$(#+field+input).va
l()+criteria=+criteria,

Then, these lines return your response:

function(response){
response = eval((+response+));
showIcon(field,response.pass,response.msg);

Am I correct so far in my understanding?

Rick


-Original Message-
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On
Behalf Of Paul
Sent: Monday, March 12, 2007 5:44 PM
To: 'jQuery Discussion.'
Subject: Re: [jQuery] Calling all CF'ers... et al...

What you described is basically what I do, Rick--not because Jorn's plugin
didn't work but because many of my form fields are validated against each
other, and database interaction is required to make that decision. (e.g.,
the validity of field Y depends on the value already entered in field X.)

Below is the validate function I call onBlur from each input.  It first sets
the field's status icon to a loading spinny, then requests validation from a
CFM file, passing the value of the current field as well as the value of the
dependent criteria, which CF handles (cfswitch/cfcase) depending on which
field is passed.  The callback receives the response and shows either a
success or error icon with a descriptive error attached in a stylish little
error message balloon.

I don't know if this is the smartest method--I'm pretty new to jQuery
myself--but it has worked very well and provides the flexibility I need.

HTH,
Paul

function validateField(field, criteria){
$(#+field+img.ico).attr(src,/images/office/ico-loading.gif);

$.get(/gateway/validate.cfm?field=+field+value=+$(#+field+input).va
l()+criteria=+criteria,
function(response){
response = eval((+response+));
showIcon(field,response.pass,response.msg);
}); 
}





___
jQuery mailing list
discuss@jquery.com
http://jquery.com/discuss/


Re: [jQuery] Calling all CF'ers... et al...

2007-03-12 Thread Klaus Hartl
Paul schrieb:
 What you described is basically what I do, Rick--not because Jorn's plugin
 didn't work but because many of my form fields are validated against each
 other, and database interaction is required to make that decision. (e.g.,
 the validity of field Y depends on the value already entered in field X.)
 
 Below is the validate function I call onBlur from each input.  It first sets
 the field's status icon to a loading spinny, then requests validation from a
 CFM file, passing the value of the current field as well as the value of the
 dependent criteria, which CF handles (cfswitch/cfcase) depending on which
 field is passed.  The callback receives the response and shows either a
 success or error icon with a descriptive error attached in a stylish little
 error message balloon.
 
 I don't know if this is the smartest method--I'm pretty new to jQuery
 myself--but it has worked very well and provides the flexibility I need.
 
 HTH,
 Paul

The good thing about such an approach is, that you have to implement 
server-side validation anyway - client-side validation can never be more 
than an addon to enhance user experience unless you can rely on 
JavaScript being enabled. So why not reuse that logic client-side as 
well for single fields. You improve the user experience while all logic 
is still in place.


-- Klaus

___
jQuery mailing list
discuss@jquery.com
http://jquery.com/discuss/


Re: [jQuery] Calling all CF'ers... et al...

2007-03-12 Thread Rick Faircloth
 The good thing about such an approach is, that you have to implement 
 server-side validation anyway - client-side validation can never be more 
 than an addon to enhance user experience unless you can rely on 
 JavaScript being enabled. So why not reuse that logic client-side as 
 well for single fields. You improve the user experience while all logic 
 is still in place.

I think your reasoning is very sound, Klaus... and besides, I know CF
a lot better than I know JS!  But I'm learning quickly!  :o)

Rick

-Original Message-
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On
Behalf Of Klaus Hartl
Sent: Monday, March 12, 2007 6:02 PM
To: jQuery Discussion.
Subject: Re: [jQuery] Calling all CF'ers... et al...


The good thing about such an approach is, that you have to implement 
server-side validation anyway - client-side validation can never be more 
than an addon to enhance user experience unless you can rely on 
JavaScript being enabled. So why not reuse that logic client-side as 
well for single fields. You improve the user experience while all logic 
is still in place.


-- Klaus

___
jQuery mailing list
discuss@jquery.com
http://jquery.com/discuss/



___
jQuery mailing list
discuss@jquery.com
http://jquery.com/discuss/


Re: [jQuery] Calling all CF'ers... et al...

2007-03-12 Thread Rick Faircloth
I'm sure it can be done with js... I just don't know how.

And besides, as Klaus pointed out, as a safeguard against
the lack of js, I guess I'd still have to perform server-side
validation, so why not just go that route and combine
the js and cf for a complete user experience involving
js on the client side and cf on the server side?

Rick

-Original Message-
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On
Behalf Of Daemach
Sent: Monday, March 12, 2007 5:47 PM
To: discuss@jquery.com
Subject: Re: [jQuery] Calling all CF'ers... et al...


Sure you can.  You can use ajax for anything you want.  

On the currency validation why can't you replace anything that is not a
number or a decimal with  ?  That should give you a valid number to
validate.

validate ele.value.replace(/[^0-9\.]/g,)







___
jQuery mailing list
discuss@jquery.com
http://jquery.com/discuss/


Re: [jQuery] Calling all CF'ers... et al...

2007-03-12 Thread Rick Faircloth
Paul, could I impose upon you to strip your example code
down to handling one field?  I don't understand everything you've
got there, and what it all refers to.

Also, could you send an example of your cf processing for a field?

This would give me enough to work on and test.  Hopefully I can figure
it out from there.

Thanks for all your help!

Rick

-Original Message-
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On
Behalf Of Paul
Sent: Monday, March 12, 2007 5:44 PM
To: 'jQuery Discussion.'
Subject: Re: [jQuery] Calling all CF'ers... et al...

What you described is basically what I do, Rick--not because Jorn's plugin
didn't work but because many of my form fields are validated against each
other, and database interaction is required to make that decision. (e.g.,
the validity of field Y depends on the value already entered in field X.)

Below is the validate function I call onBlur from each input.  It first sets
the field's status icon to a loading spinny, then requests validation from a
CFM file, passing the value of the current field as well as the value of the
dependent criteria, which CF handles (cfswitch/cfcase) depending on which
field is passed.  The callback receives the response and shows either a
success or error icon with a descriptive error attached in a stylish little
error message balloon.

I don't know if this is the smartest method--I'm pretty new to jQuery
myself--but it has worked very well and provides the flexibility I need.

HTH,
Paul

function validateField(field, criteria){
$(#+field+
img.ico).attr(src,/images/office/ico-loading.gif);
$.get(/gateway/validate.cfm?field=+field+value=+$(#+field+
input).val()+criteria=+criteria,
function(response){
response = eval((+response+));
showIcon(field,response.pass,response.msg);
}); 
}





___
jQuery mailing list
discuss@jquery.com
http://jquery.com/discuss/


Re: [jQuery] Calling all CF'ers... et al...

2007-03-12 Thread Paul
It would normally be smart, Klaus, but in my case not much would be gained.
I'm building an intranet app, and at 100 mps the ajax calls come back
extremely quickly.  (truthfully I've yet to see my spinny graphic show
up...)

-Original Message-
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On
Behalf Of Klaus Hartl
Sent: Monday, March 12, 2007 3:02 PM
To: jQuery Discussion.
Subject: Re: [jQuery] Calling all CF'ers... et al...

Paul schrieb:
 What you described is basically what I do, Rick--not because Jorn's plugin
 didn't work but because many of my form fields are validated against each
 other, and database interaction is required to make that decision. (e.g.,
 the validity of field Y depends on the value already entered in field X.)
 
 Below is the validate function I call onBlur from each input.  It first
sets
 the field's status icon to a loading spinny, then requests validation from
a
 CFM file, passing the value of the current field as well as the value of
the
 dependent criteria, which CF handles (cfswitch/cfcase) depending on which
 field is passed.  The callback receives the response and shows either a
 success or error icon with a descriptive error attached in a stylish
little
 error message balloon.
 
 I don't know if this is the smartest method--I'm pretty new to jQuery
 myself--but it has worked very well and provides the flexibility I need.
 
 HTH,
 Paul

The good thing about such an approach is, that you have to implement 
server-side validation anyway - client-side validation can never be more 
than an addon to enhance user experience unless you can rely on 
JavaScript being enabled. So why not reuse that logic client-side as 
well for single fields. You improve the user experience while all logic 
is still in place.


-- Klaus

___
jQuery mailing list
discuss@jquery.com
http://jquery.com/discuss/


___
jQuery mailing list
discuss@jquery.com
http://jquery.com/discuss/


Re: [jQuery] Calling all CF'ers... et al...

2007-03-12 Thread Jörn Zaefferer
Klaus Hartl schrieb:
 Paul schrieb:
   
 What you described is basically what I do, Rick--not because Jorn's plugin
 didn't work but because many of my form fields are validated against each
 other, and database interaction is required to make that decision. (e.g.,
 the validity of field Y depends on the value already entered in field X.)

 Below is the validate function I call onBlur from each input.  It first sets
 the field's status icon to a loading spinny, then requests validation from a
 CFM file, passing the value of the current field as well as the value of the
 dependent criteria, which CF handles (cfswitch/cfcase) depending on which
 field is passed.  The callback receives the response and shows either a
 success or error icon with a descriptive error attached in a stylish little
 error message balloon.

 I don't know if this is the smartest method--I'm pretty new to jQuery
 myself--but it has worked very well and provides the flexibility I need.

 HTH,
 Paul
 

 The good thing about such an approach is, that you have to implement 
 server-side validation anyway - client-side validation can never be more 
 than an addon to enhance user experience unless you can rely on 
 JavaScript being enabled. So why not reuse that logic client-side as 
 well for single fields. You improve the user experience while all logic 
 is still in place.
   
One of the long-term targets of the validation plugin is to generate as 
much of the client-side validation rules as possible based on the 
serverside rules, without additional ajax requests.

Until that is available in any form, you could use the validation plugin 
to display your messages (returned from your AJAX request).

See this demo: 
http://jquery.bassistance.de/validate/demo-test/ajaxSubmit-intergration-demo.html

The relevant client code is this:

var v = $(#form).validate({
submitHandler: function(form) {
$(form).ajaxSubmit({
dataType: json,
after: function(result) {
if(result.status) {
v.showErrors(result.data);
}   
}
});
}
});

In that example, result.data looks like this:

{'password': 'Your password is wrong (must be foobar).'}

That way you can use the same setup for displaying both clientside and 
serverside validation errors. Useful?

-- 
Jörn Zaefferer

http://bassistance.de


___
jQuery mailing list
discuss@jquery.com
http://jquery.com/discuss/


Re: [jQuery] Calling all CF'ers... et al...

2007-03-12 Thread Paul
Rick, I'll see if I can make time for this tonight...  It's 65 outside and
my road bike beckons seductively from the garage.  Unfortunately my desire
to help is overwhelmed by the end of a long, cold winter in the mountains...

-Original Message-
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On
Behalf Of Rick Faircloth
Sent: Monday, March 12, 2007 3:35 PM
To: 'jQuery Discussion.'
Subject: Re: [jQuery] Calling all CF'ers... et al...

Paul, could I impose upon you to strip your example code
down to handling one field?  I don't understand everything you've
got there, and what it all refers to.

Also, could you send an example of your cf processing for a field?

This would give me enough to work on and test.  Hopefully I can figure
it out from there.

Thanks for all your help!

Rick

-Original Message-
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On
Behalf Of Paul
Sent: Monday, March 12, 2007 5:44 PM
To: 'jQuery Discussion.'
Subject: Re: [jQuery] Calling all CF'ers... et al...

What you described is basically what I do, Rick--not because Jorn's plugin
didn't work but because many of my form fields are validated against each
other, and database interaction is required to make that decision. (e.g.,
the validity of field Y depends on the value already entered in field X.)

Below is the validate function I call onBlur from each input.  It first sets
the field's status icon to a loading spinny, then requests validation from a
CFM file, passing the value of the current field as well as the value of the
dependent criteria, which CF handles (cfswitch/cfcase) depending on which
field is passed.  The callback receives the response and shows either a
success or error icon with a descriptive error attached in a stylish little
error message balloon.

I don't know if this is the smartest method--I'm pretty new to jQuery
myself--but it has worked very well and provides the flexibility I need.

HTH,
Paul

function validateField(field, criteria){
$(#+field+
img.ico).attr(src,/images/office/ico-loading.gif);
$.get(/gateway/validate.cfm?field=+field+value=+$(#+field+
input).val()+criteria=+criteria,
function(response){
response = eval((+response+));
showIcon(field,response.pass,response.msg);
}); 
}





___
jQuery mailing list
discuss@jquery.com
http://jquery.com/discuss/


___
jQuery mailing list
discuss@jquery.com
http://jquery.com/discuss/


Re: [jQuery] Calling all CF'ers... et al...

2007-03-12 Thread Rick Faircloth
Sounds good to me, but I'm not knowledgeable or experienced
enough with all this to evaluate an approach.

The biggest concern I have, especially when it comes to logins
and validation, is that a person might have js turned off (although
my stats show that is a tiny amount, less than 1 percent of people
that visit my sites) and then not be able to login or successfully
input data with a js-validated form.

Rick




One of the long-term targets of the validation plugin is to generate as 
much of the client-side validation rules as possible based on the 
serverside rules, without additional ajax requests.

Until that is available in any form, you could use the validation plugin 
to display your messages (returned from your AJAX request).

See this demo: 
http://jquery.bassistance.de/validate/demo-test/ajaxSubmit-intergration-demo
.html

The relevant client code is this:

var v = $(#form).validate({
submitHandler: function(form) {
$(form).ajaxSubmit({
dataType: json,
after: function(result) {
if(result.status) {
v.showErrors(result.data);
}   
}
});
}
});

In that example, result.data looks like this:

{'password': 'Your password is wrong (must be foobar).'}

That way you can use the same setup for displaying both clientside and 
serverside validation errors. Useful?

-- 
Jörn Zaefferer

http://bassistance.de


___
jQuery mailing list
discuss@jquery.com
http://jquery.com/discuss/



___
jQuery mailing list
discuss@jquery.com
http://jquery.com/discuss/


Re: [jQuery] Calling all CF'ers... et al...

2007-03-12 Thread Rick Faircloth
Hey, Paul!  You a cyclist, too?

I know exactly what you're feeling!  It's finally warm
enough for me around here in Georgia (US).

I like it 60 and up.  I know, for some that's the tropics,
but when you're raised in the heat and humidity, man
that downright frigid.  :o)

I sent my bike into the shop today for some repair work.
Got to get a tune-up and the pedals replaced.  (Lost some
ball bearing in there somewhere)

I try to put in 25 miles a day during warm weather.  I don't
mind the rain, but man, do I hate the cold!

Where are you located?

Rick

-Original Message-
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On
Behalf Of Paul
Sent: Monday, March 12, 2007 7:08 PM
To: 'jQuery Discussion.'
Subject: Re: [jQuery] Calling all CF'ers... et al...

Rick, I'll see if I can make time for this tonight...  It's 65 outside and
my road bike beckons seductively from the garage.  Unfortunately my desire
to help is overwhelmed by the end of a long, cold winter in the mountains...





___
jQuery mailing list
discuss@jquery.com
http://jquery.com/discuss/


Re: [jQuery] Calling all CF'ers... et al...

2007-03-12 Thread Paul
Okay as promised Will, here's what I do.  It's most certainly not the most
efficient method, since it's my first go 'round, but it does what I ask it
to.  I've added a few comments inline for you.  (After pasting in here I
can't even tell what's going on--and I wrote it!  Paste this into your
editor to get a clearer view...) 

A) Here is a snippet of the original html.  It simply presents a
field/label.

div class=row id=shipto_location
div class=requiredShip-to location:/div input type=text
maxlength=75 !--- these inputs are all autocomplete text fields ---
img src= width=14 height=14 class=ico  !--- call $(.row
img).hide() on page load ---
/div

B) Here is the jQuery bit that binds a behavior to the blur event.  In my
case this comes from a Taconite response, but I think you'd need it in your
document.ready() function for testing.  

$(#shipto_location input).blur(function (){
/* when the input within #shipto_location loses focus, pass the name
of the input and the value of the customer name input to be validated */
validateField('shipto_location',$(#customer_name input).val());
});

C) As posted before, here is the validateField function called by part B
above.

function validateField(field, criteria){
/* change the src of the row's icon (in this example,
#shipto_location img.ico) to the loading spinny */
$(#+field+
img.ico).attr(src,/images/office/ico-loading.gif);
/* pass the name of the field to validate, the value of said field,
and the value of an optional criteria (in this case, $(#customer_name
input).val()) */
$.get(/gateway/validate.cfm?field=+field+value=+$(#+field+
input).val()+criteria=+criteria,
function(response){
/* evaluate the json response */
response = eval((+response+));
/* display the appropriate icon; showIcon
can be called after either ajax or local validation */
showIcon(field,response.pass,response.msg);
}); 
}

D) Here's the relevant snippet from validate.cfm:

!--- the cfswitch expression is url.field ---
cfcase value=shipto_location delimiters=|
cfquery name=q datasource=Yard
select s.shipto_id
from  shipto_locations as s inner join
  customers as c on s.customer_id = c.customer_id
where (s.shipto = cfqueryparam value=#url.value#) and
(c.customer = cfqueryparam value=#url.criteria#)
/cfquery
cfif q.recordcount GT 0
!--- The value of st[pass] is set to false by default
above the cfswitch block ---
cfset st[pass]=true
cfelse
cfset st[msg]='#url.value#' is not a valid
#url.criteria# location.
/cfif
/cfcase
...
!--- after the cfswitch expression, display the struct in json format (you
have json.cfc, right?) ---
cfoutput#json.encode(st)#/cfoutput

You can see the result of all this:
http://paul.malan.org/jQuery/validation-example.png.  

(You may also get some use out of Chris Jordan's new CF/jQuery function set
- http://cjordan.us/ - for local validation.)

Let me know if this helps or confuses...
Paul

-Original Message-
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On
Behalf Of Rick Faircloth
Sent: Monday, March 12, 2007 3:35 PM
To: 'jQuery Discussion.'
Subject: Re: [jQuery] Calling all CF'ers... et al...

Paul, could I impose upon you to strip your example code
down to handling one field?  I don't understand everything you've
got there, and what it all refers to.

Also, could you send an example of your cf processing for a field?

This would give me enough to work on and test.  Hopefully I can figure
it out from there.

Thanks for all your help!

Rick

-Original Message-
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On
Behalf Of Paul
Sent: Monday, March 12, 2007 5:44 PM
To: 'jQuery Discussion.'
Subject: Re: [jQuery] Calling all CF'ers... et al...

What you described is basically what I do, Rick--not because Jorn's plugin
didn't work but because many of my form fields are validated against each
other, and database interaction is required to make that decision. (e.g.,
the validity of field Y depends on the value already entered in field X.)

Below is the validate function I call onBlur from each input.  It first sets
the field's status icon to a loading spinny, then requests validation from a
CFM file, passing the value of the current field as well as the value of the
dependent criteria, which CF handles (cfswitch/cfcase) depending on which
field is passed.  The callback receives the response and shows either a
success or error icon with a descriptive error attached in a stylish little
error message balloon.

I don't know if this is the smartest method--I'm pretty new to jQuery
myself--but it has worked very well and provides the flexibility I need.

HTH