Here i am validating the IP address entered in a textbox through PHP.
 $('#check_ip').click(function() {
 var iptext = $('#Ip_Txt').val();   
 $.ajax({
     type : "POST",
     url : "mypage.php",
     data : { iptext : iptext , testconn : "yes" },
     success : function(data) {                     
     }      
 });
 });
And my PHP
if(isset($_REQUEST['testconn'])){
if ( $_SERVER['REQUEST_METHOD'] == "POST" )
{
    $input = $_POST['iptext '];
    if (preg_match( "/^(([1-9]?[0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5]).){3}([1-9]?[0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])$/", $input))
    {
        echo "Valid IP";
    }
    else
    {
        echo "Invalid IP";
    }
}   
}
Everything is working fine. But i need to display echo Valid IP or Invalid IP in javascript alert after clicking the check_ip button.
 
     
     
     
     
     
    