[jQuery] Help with error script
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META content="text/html; charset=us-ascii" http-equiv=Content-Type>
<META name=GENERATOR content="MSHTML 8.00.6001.18813"></HEAD>
<BODY>
<DIV><FONT size=2 face="Trebuchet MS"><SPAN class=587305115-15092009>I have an
ajax function that checks fields to validate and display error
messages.</SPAN></FONT></DIV>
<DIV><FONT size=2 face="Trebuchet MS"><SPAN
class=587305115-15092009></SPAN></FONT> </DIV>
<DIV><FONT size=2 face="Trebuchet MS"><SPAN class=587305115-15092009>There are
multiple messages depending on the error per field in some cases, to short, to
long, already taken, invalid, cant be empty and so on....you get the
idea.</SPAN></FONT></DIV>
<DIV><FONT size=2 face="Trebuchet MS"><SPAN
class=587305115-15092009></SPAN></FONT> </DIV>
<DIV><FONT size=2 face="Trebuchet MS"><SPAN class=587305115-15092009>My function
is like this:</SPAN></FONT></DIV>
<DIV><FONT size=2 face="Trebuchet MS"><SPAN
class=587305115-15092009></SPAN></FONT> </DIV>
<DIV><FONT size=2 face="Trebuchet MS"><SPAN
class=587305115-15092009>function(error) {</SPAN></FONT></DIV>
<DIV> </DIV>
<DIV><FONT size=2 face="Trebuchet MS"><SPAN
class=587305115-15092009>
if(error.length != 0)
{ <BR> </SPAN></FONT></DIV>
<DIV> </DIV>
<DIV><FONT size=2 face="Trebuchet MS"><SPAN
class=587305115-15092009>
if ( $('#' + fieldName + '-exists').length == 0 )
<BR> {
<BR> $('#' +
fieldName).after('<div class="error-message" id="'+ fieldName +'-exists">'
+ error + '</div>');<BR>
}<BR>
<BR>
}<BR>
else
{<BR>
$('#' + fieldName +
'-exists').remove();<BR>
}<BR>
});</SPAN></FONT></DIV>
<DIV><FONT size=2 face="Trebuchet MS"><SPAN
class=587305115-15092009></SPAN></FONT> </DIV>
<DIV><FONT size=2 face="Trebuchet MS"><SPAN class=587305115-15092009>But the
error never changes once 1 is called so if to short it says too short....fix the
problem and it only shows too short never any other message. How can i remove
the message if its fixed but still return anothererror if it
exists?</SPAN></FONT></DIV>
<DIV><FONT size=2 face="Trebuchet MS"><SPAN
class=587305115-15092009></SPAN></FONT> </DIV>
<DIV><FONT size=2 face="Trebuchet MS"><SPAN class=587305115-15092009>I tried if
( $('#' + fieldName + '-exists').length != error ) </SPAN></FONT></DIV>
<DIV><FONT size=2 face="Trebuchet MS"><SPAN class=587305115-15092009>so if the
error is different display the error but it doesnot remove the original
error....</SPAN></FONT></DIV>
<DIV><FONT size=2 face="Trebuchet MS"><SPAN
class=587305115-15092009></SPAN></FONT> </DIV>
<DIV><FONT size=2 face="Trebuchet MS"><SPAN
class=587305115-15092009>Ideas?</SPAN></FONT></DIV>
<DIV><FONT size=2 face="Trebuchet MS"><SPAN
class=587305115-15092009></SPAN></FONT> </DIV>
<DIV><FONT size=2 face="Trebuchet MS"><SPAN
class=587305115-15092009>Thanks</SPAN></FONT></DIV>
<DIV><FONT size=2 face="Trebuchet MS"><SPAN
class=587305115-15092009></SPAN></FONT> </DIV>
<DIV align=left><FONT size=2 face=Arial>Dave </FONT></DIV></BODY></HTML>