Hi,
I basically have this script which is working fine, but only works wen I tab off the form, I would like to change it for a submit buttin, I believe I have to change .blur to something else, can anyone help me in the right place? thanks, below are my scripts
Code:
<script src="jquery.js" type="text/javascript" language="javascript"></script>
<script language="javascript">
$(document).ready(function()
{
$("#username").blur(function()
{
//remove all the class add the messagebox classes and start fading
$("#msgbox").removeClass().addClass('messagebox').text('Checking...').fadeIn("slow");
//check the postcode exists or not from ajax
$.post("post_code.php",{ user_name:$(this).val() } ,function(data)
{
if(data=='no') //if postcode not avaiable
{
$("#msgbox").fadeTo(200,0.1,function() //start fading the messagebox
{
//add message and change the class of the box and start fading
$(this).html('Sorry We Do Not Cover Your Area').addClass('messageboxerror').fadeTo(900,1);
});
}
else
{
$("#msgbox").fadeTo(200,0.1,function() //start fading the messagebox
{
//add message and change the class of the box and start fading
$(this).html('We Cover Your Area').addClass('messageboxok').fadeTo(900,1);
});
}
});
});
});
</script>
Code:
<input name="username" type="text" id="username" value="" maxlength="15" onChange="javascript:this.value=this.value.toLowerCase();"/>
<span id="msgbox" style="display:none"></span>
thanks