Re: [jQuery] Code simplifying request.

2007-03-21 Thread Rob Desbois
Ok first off you should cache the result of the search as otherwise it'll be performed every time. Then, you can just chain the operations on input#rxt_forename straight, except for one part. When you modify a jQuery object, e.g. with addClass(), the function returns the jQuery object. This chaini

Re: [jQuery] Code simplifying request.

2007-03-21 Thread David Dexter
_ From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Luc Pestille Sent: Wednesday, March 21, 2007 9:40 AM To: jQuery Discussion. Subject: [jQuery] Code simplifying request. Hi all, I've got some simple validation to do (not enough to use one of the form plugin

Re: [jQuery] Code simplifying request.

2007-03-21 Thread Alex Cook
_ From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Luc Pestille Sent: Wednesday, March 21, 2007 9:40 AM To: jQuery Discussion. Subject: [jQuery] Code simplifying request. Hi all, I've got some simple validation to do (not enough to use one of the form

Re: [jQuery] Code simplifying request.

2007-03-21 Thread Marc Jansen
Hi Luc, This is a little smaller... yet surely not perfect $('form#checkout').submit(function() { var $forename = $('input#rxt_forename'); var forename = $forename.get(0); if($forename.val() == '' ){ forename.focus(); $forename.addClass("required").siblings("span.error").show();

[jQuery] Code simplifying request.

2007-03-21 Thread Luc Pestille
Hi all, I've got some simple validation to do (not enough to use one of the form plugins), and have this; // when the form is submitted $('form#checkout').submit( function(){ // if field has something in it, do submit actions, otherwise write out error if( $('input#rxt_forename').val()