two scripts conflict with one another when used together
I have two different scripts I am using on a web form, one which highlights the field when the mouse focuses on a field and another which checks the info and submits. They work fine separately, but together there is a conflict. Any ideas on how to resolve the conflict?
Here are the two scripts.
- <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.1/jquery.min.js"></script>
<script language="javascript">
// Developed by Roshan Bhattarai
// Visit http://roshanbh.com.np for this script and more.
// This notice MUST stay intact for legal use
$(document).ready(function()
{
$("#login_form").submit(function()
{
//remove all the class add the messagebox classes and start fading
$("#msgbox").removeClass().addClass('messagebox').text('Validating....').fadeIn(1000);
//check the username exists or not from ajax
$.post("login.php", {username:$('#username').val(),password:$('#password').val()} ,function(data)
{
//alert(data);
if(data==1) //if correct login detail
{
$("#msgbox").fadeTo(200,0.1,function(data) //start fading the messagebox
{
//add message and change the class of the box and start fading
$(this).html('Success!..Logging in.....').addClass('messageboxok').fadeTo(900,1,
function()
{
//redirect to secure page
document.location='EditorExam.php';
});
});
}
else
{
$("#msgbox").fadeTo(200,0.1,function(data) //start fading the messagebox
{
//add message and change the class of the box and start fading
$(this).html('You have entered an incorrect login<br /> please try again!').addClass('messageboxerror').fadeTo(900,1).delay(5000).fadeTo(900,0);
});
}
});
return false; //not to post the form physically
});
//now call the ajax also focus move from
$("#password").blur(function(data)
{
$("#login_form").trigger('submit');
});
});
</script>
- <script type="text/javascript" src="http://jqueryjs.googlecode.com/files/jquery-1.3.js"></script>
<script type="text/javascript">
$(document).ready(function() {
$('input[type="text"]').addClass("idleField");
$('input').focus(function() {
$(this).removeClass("idleField").addClass("focusField");
if (this.value == this.defaultValue){
this.value = '';
}
if(this.value != this.defaultValue){
this.select();
}
});
$('input').blur(function() {
$(this).removeClass("focusField").addClass("idleField");
if ($.trim(this.value) == ''){
this.value = (this.defaultValue ? this.defaultValue : '');
}
});
});
</script>