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
_
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
_
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
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();
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()