[jQuery] Validation function help request
<HTML >
<HEAD>
<META http-equiv="Content-Type" content="text/html; charset=us-ascii">
<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 dir=ltr align=left><SPAN class=146522415-21052007></SPAN><FONT
face=Tahoma><FONT size=2>I<SPAN class=146522415-21052007><FONT
face="Trebuchet MS"> don't think this came through when i origianlly sent
it, apologies if you've seen it twice
now... </FONT></SPAN></FONT></FONT><BR></DIV>
<DIV></DIV>
<DIV><SPAN class=741283311-21052007><FONT face="Trebuchet MS" size=2>Hi
all,</FONT></SPAN></DIV>
<DIV><SPAN class=741283311-21052007><FONT face="Trebuchet MS" size=2>Having
tried a few validation plugins, none can do exactly what I want (given the time
I have to spend on it), so I'm doing it the manual way, but I can't figure out
how to turn my repititions into a function. I have this;</FONT></SPAN></DIV>
<DIV><SPAN class=741283311-21052007><FONT face="Trebuchet MS"
size=2></FONT></SPAN> </DIV>
<DIV><SPAN class=741283311-21052007><FONT face="Trebuchet MS"
size=2></FONT></SPAN> </DIV>
<DIV><SPAN class=741283311-21052007><FONT face="Trebuchet MS"
size=2>//validation for forms<BR> $('#admin-quotes').submit(
function(){<BR> <BR> var inputcheck =
$("#person");<BR> // if field has something in it, do submit
actions, otherwise write out error<BR> if( inputcheck.val() ==
'' ){<BR> // add class to change
colour<BR> inputcheck.addClass("required").get(0).focus();<BR> return
false;<BR> }else{<BR> inputcheck.removeClass("required");<BR> }<BR> <BR> var
inputcheck = $("#position");<BR> // if field has something in
it, do submit actions, otherwise write out error<BR> if(
inputcheck.val() == '' ){<BR> // add class to change
colour<BR> inputcheck.addClass("required").get(0).focus();<BR> return
false;<BR> }else{<BR> inputcheck.removeClass("required");<BR> }<BR> <BR> });</FONT></SPAN></DIV>
<DIV><FONT face="Trebuchet MS" size=2></FONT> </DIV>
<DIV><FONT face="Trebuchet MS" size=2></FONT> </DIV>
<DIV><FONT face="Trebuchet MS" size=2><SPAN class=741283311-21052007>and
obviously it's ripe for a function like;</SPAN></FONT></DIV>
<DIV><FONT face="Trebuchet MS" size=2><SPAN
class=741283311-21052007></SPAN></FONT> </DIV>
<DIV><FONT face="Trebuchet MS" size=2><SPAN class=741283311-21052007>function
simplecheck(fieldid){</SPAN></FONT></DIV>
<DIV><FONT face="Trebuchet MS" size=2><SPAN
class=741283311-21052007></SPAN></FONT> </DIV>
<DIV><FONT face="Trebuchet MS" size=2><SPAN
class=741283311-21052007> var inputcheck =
$(fieldid);<BR> // if field has something in it, do submit
actions, otherwise write out error<BR> if( inputcheck.val() ==
'' ){<BR> // add class to change
colour<BR> inputcheck.addClass("required").get(0).focus();<BR> return
false;<BR> }else{<BR> inputcheck.removeClass("required");<BR> }</SPAN></FONT></DIV>
<DIV><FONT face="Trebuchet MS" size=2><SPAN
class=741283311-21052007></SPAN></FONT> </DIV>
<DIV><FONT face="Trebuchet MS" size=2><SPAN
class=741283311-21052007>}</SPAN></FONT></DIV>
<DIV><FONT face="Trebuchet MS" size=2></FONT> </DIV>
<DIV><FONT face="Trebuchet MS" size=2></FONT> </DIV>
<DIV><SPAN class=741283311-21052007><FONT face="Trebuchet MS" size=2>But I can't
get the right combinations of return true/false and calling the fuction to work
whereby the form does the same with a function as it does with the 'manual'
checking. Can anyone forge it into something that works?</FONT></SPAN></DIV>
<DIV><SPAN class=741283311-21052007><FONT face="Trebuchet MS"
size=2></FONT></SPAN> </DIV>
<DIV><SPAN class=741283311-21052007><FONT face="Trebuchet MS"
size=2>TIA!</FONT></SPAN></DIV>
<DIV align=left><FONT face="Trebuchet MS" size=2>
<P><B>Luc Pestille</B><BR>Web Designer</P></FONT></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>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 jquery-en@googlegroups.com and may contain information that is confidential, subject to copyright or constitutes a trade secret. If you are not jquery-en@googlegroups.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><IMG ALT="in2 logo" HSPACE="0" SRC="cid:a2361d2395@c29448e4-5269" ALIGN="baseline" BORDER="0"></FONT>
</DIV>
</TD>
</TR>
</TBODY>
</TABLE>
</DIV></BODY></HTML>