[jQuery] Validation question
<!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=124554917-31082009>I have this
script</SPAN></FONT></DIV>
<DIV><FONT size=2 face="Trebuchet MS"><SPAN
class=124554917-31082009></SPAN></FONT> </DIV>
<DIV><FONT size=2 face="Trebuchet MS"><SPAN
class=124554917-31082009>$(document).ready( function() {</SPAN></FONT></DIV>
<DIV> </DIV>
<DIV><FONT size=2 face="Trebuchet MS"><SPAN
class=124554917-31082009> $('#username').blur( function ()
{</SPAN></FONT></DIV>
<DIV> </DIV>
<DIV><FONT size=2 face="Trebuchet MS"><SPAN
class=124554917-31082009> fieldName =
$(this).attr('id');<BR> fieldValue =
$(this).val();</SPAN></FONT></DIV>
<DIV> </DIV>
<DIV><FONT size=2 face="Trebuchet MS"><SPAN
class=124554917-31082009>
$.post('/users/ajax_validate',
{<BR>
field:
fieldName,<BR>
value:
fieldValue<BR>
},<BR>
function(error) {</SPAN></FONT></DIV>
<DIV> </DIV>
<DIV><FONT size=2 face="Trebuchet MS"><SPAN
class=124554917-31082009>
if(error.length != 0)
{
</SPAN></FONT></DIV>
<DIV> </DIV>
<DIV><FONT size=2 face="Trebuchet MS"><SPAN
class=124554917-31082009>
$('#username').after('<div class="error-message" id="'+ fieldName
+'-exists">' + error +
'</div>');<BR>
}<BR>
else
{<BR>
$('#' + fieldName +
'-exists').remove();<BR>
}<BR>
});<BR> }); </SPAN></FONT></DIV>
<DIV> </DIV>
<DIV><FONT size=2 face="Trebuchet MS"><SPAN class=124554917-31082009>});
</SPAN></FONT></DIV>
<DIV><FONT size=2 face="Trebuchet MS"><SPAN
class=124554917-31082009></SPAN></FONT> </DIV>
<DIV><FONT size=2 face="Trebuchet MS"><SPAN class=124554917-31082009>Which sends
a requet to determine if the username is taken...pretty simple if so it displays
Please choose another message. My problem is if the user goes back to the field
and then leaves without changing it it sends the request again and then shows
</SPAN></FONT></DIV>
<DIV><FONT size=2 face="Trebuchet MS"><SPAN class=124554917-31082009>"Please
choose another name"</SPAN></FONT></DIV>
<DIV><FONT size=2 face="Trebuchet MS"><SPAN class=124554917-31082009><SPAN
class=124554917-31082009>"Please choose another name"</SPAN></SPAN></FONT></DIV>
<DIV><FONT size=2 face="Trebuchet MS"><SPAN class=124554917-31082009><SPAN
class=124554917-31082009></SPAN></SPAN></FONT> </DIV>
<DIV><FONT size=2 face="Trebuchet MS"><SPAN class=124554917-31082009><SPAN
class=124554917-31082009>How can I modify the script so if there is an error and
not fixed to leave the message and not repeat it?</SPAN></SPAN></FONT></DIV>
<DIV> </DIV>
<DIV align=left><FONT size=2 face=Arial>Dave </FONT></DIV></BODY></HTML>