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
You don't need the elements in the selector (i.e. form / input). The fastest
way to select is on the unique id.
Also, instead of calling the same jQuery selector over and over set it to a
local variable.
$('#checkout').submit( function(){
// if field has something in it, do su
Try something like this...
$('form#checkout').submit( function(){
//Refernce the elm if you are going to $() it more then once
$elm = $('input#rxt_forename');
if($elm.val() == ''){
//Double check the end() usage here, should work
elm.addCla
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();