Everything is going fine jst a little bit mistake only
when i press enter it will send the value througn $.post(). after success the page refreshes why so
and if i use some other keycode it will remain same value inserted but no refresh
<script>
$(document).ready(function(){
$('#newNumber').focus();
$('#newNumber').keypress(function(e){
var code=e.keyCode;
//alert(code);
if(code==61)
{
var nno=$('#newNumber').val();
$('#load').show();
if(nno=="")
{
$('#load').hide();
$('#alertBox').show();
$('#newNumber').focus();
$('#alertBox').html("<div class=error><span id=alerttext class='alerttext'>Empty Field</span><div id=close class='close'><img src='images/close.png'/></div></div>");
$('#close').click(function(){$('#alertBox').fadeOut(2000);});
}
else
{
$.post("NumberAction/addAction.php",$('#contentForm').serialize(),function(result){
if(result=="yes")
{
$('#load').hide();
$('#alertBox').show();
$('#alertBox').html("<div class=warning><span id=alerttext class='alerttext'>Already Exists</span><div id=close class='close'><img src='images/close.png'/></div></div>");
$('#newNumber').val("");
$('#newNumber').focus();
$('#close').click(function(){$('#alertBox').fadeOut(2000);});
}
else if(result=="done")
{
$('#load').hide();
$('#alertBox').show();
$('#alertBox').html("<div class=success><span id=alerttext class='alerttext'>New number is added</span><div id=close class='close'><img src='images/close.png'/></div></div>");
$('#newNumber').val("");
$('#newNumber').focus();
$('#close').click(function(){$('#alertBox').fadeOut(2000);});
}
else if(result=="error")
{
$('#load').hide();
$('#alertBox').show();
$('#alertBox').html("<div class=error><span id=alerttext class='alerttext'>Error in adding</span><div id=close class='close'><img src='images/close.png'/></div></div>");
$('#newNumber').val("");
$('#newNumber').focus();
$('#close').click(function(){$('#alertBox').fadeOut(2000);});
}
})
}
}
})
})
</script>
Now values is going but when i press enter it will send the value but also it will refresh the page so that i am not able to use the Enter key code