[jQuery] Code simplifying request.
<HTML >
<HEAD>
<META http-equiv="Content-Type" content="text/html; charset=us-ascii">
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=UTF-16">
<META content="MSHTML 6.00.2900.2963" name=GENERATOR></HEAD>
<BODY >
<DIV>
<TABLE CELLSPACING="0" CELLPADDING="0" BORDER="0"><!-- Letter Heading -->
<TBODY>
<TR>
<TD><!-- Left margin -->
</TD>
<TD>
<DIV><SPAN class=124063716-21032007><FONT face="Trebuchet MS" size=2>Hi
all,</FONT></SPAN></DIV>
<DIV><SPAN class=124063716-21032007><FONT face="Trebuchet MS" size=2>I've got
some simple validation to do (not enough to use one of the form plugins), and
have this;</FONT></SPAN></DIV>
<DIV><SPAN class=124063716-21032007><FONT face="Trebuchet MS"
size=2></FONT></SPAN> </DIV>
<DIV><SPAN class=124063716-21032007><FONT face="Trebuchet MS" size=2>// when the
form is submitted<BR> $('form#checkout').submit(
function(){<BR> <BR> // if field has something in
it, do submit actions, otherwise write out error<BR> if(
$('input#rxt_forename').val() == '' ){<BR> // add class
to change
colour<BR> $('input#rxt_forename').addClass("required").get(0).focus();<BR> $('input#rxt_forename').siblings("span.error").show();<BR> return
false;<BR> }else{<BR> $('input#rxt_forename').removeClass("required");<BR> $('input#rxt_forename').siblings("span.error").hide();<BR> }</FONT></SPAN></DIV>
<DIV><SPAN class=124063716-21032007><FONT face="Trebuchet MS"
size=2></FONT></SPAN> </DIV>
<DIV><SPAN class=124063716-21032007><FONT face="Trebuchet MS" size=2>How can i
simplify it? I would have thought replacing the input selector with $(this)
would work, but it doesn't, and I'm sure the class/siblings processes could
be chained...</FONT></SPAN></DIV>
<DIV><SPAN class=124063716-21032007><FONT face="Trebuchet MS"
size=2></FONT></SPAN> </DIV>
<DIV><SPAN class=124063716-21032007><FONT face="Trebuchet MS"
size=2>Thanks,</FONT></SPAN></DIV>
<DIV><SPAN class=124063716-21032007><FONT face="Trebuchet MS"
size=2></FONT></SPAN> </DIV>
<DIV> </DIV>
<DIV align=left>
<TABLE align=left>
<TBODY>
<TR>
<TD vAlign=top><IMG height=33
src="http://www.in2.co.uk/images/in2-logo-small.gif" width=30></TD>
<TD width=7></TD>
<TD vAlign=top><FONT face="Trebuchet MS" size=2>
<P><B>Luc Pestille</B><BR>Web Designer </P>
<P>e: luc.pestille@in2.co.uk<BR>t: +44 (0)1628 899 700<BR>f: +44 (0)1628
899 701 </P></FONT></TD></TR></TBODY></TABLE></DIV>
<DIV> </DIV></TD>
<TD><!-- Right margin -->
</TD>
</TR><!-- Disclaimer -->
<TR>
<TD COLSPAN="3"><BR>
<DIV STYLE="FONT-SIZE: 7pt; COLOR: gray; FONT-FAMILY: verdana" ALIGN="justify">In2<BR>Thames House<BR>Mere Park<BR>Dedmere Road<BR>Marlow<BR>Bucks<BR>SL7 1PB<BR><BR>Tel 01628 899700<BR>Fax 01628 899701<BR>e: <A HREF="mailto:sales@in2.co.uk">sales@in2.co.uk</A><BR>i: <A HREF="http://www.in2.co.uk/">www.in2.co.uk</A><BR><BR><FONT COLOR="silver">This message (and any associated files) is intended only for the use of discuss@jquery.com and may contain information that is confidential, subject to copyright or constitutes a trade secret. If you are not discuss@jquery.com you are hereby notified that any dissemination, copying or distribution of this message, or files associated with this message, is strictly prohibited. If you have received this message in error, please notify us immediately by replying to the message and deleting it from your computer. Messages sent to and from us may be monitored. Any views or opinions presented are solely those of the author Luc.Pestille@in2.co.uk and do not necessarily represent those of the company. <BR><BR></FONT>
</DIV>
</TD>
</TR>
</TBODY>
</TABLE>
</DIV></BODY></HTML>
_______________________________________________
jQuery mailing list
discuss@jquery.com
http://jquery.com/discuss/