GIF89a php
Current File : /home/hencockfreshchic/public_html/admin.cpanel/uploadjs/validNewPincode.js
function validNewPincode(ops){
	var newpin=$("#newpin").val();
	var pin_status=$("#pin_status").val();

	var regexp;
   regexp = /^[-+]?\d*\.?\d*$/;
   if (!regexp.test(newpin))
   {
      alert("Invalid pincode");
      $("#newpin").focus();
      return false;
   }
   if (newpin == "")
   {
      alert("Enter pincode");
      $("#newpin").focus();
      return false;
   }
   if (newpin.length < 5)
   {
      alert("Enter pincode require minimum 5 words");
      $("#newpin").focus();
      return false;
   }
   if (newpin.length > 15)
   {
      alert("Enter pincode max limit exceed | words max limit 15");
      $("#newpin").focus();
      return false;
   }
   if(pin_status=="")
   {
   	alert("Invalid availability status");
      $("#pin_status").focus();
      return false;
   }


	if (window.XMLHttpRequest) {
            xmlhttp = new XMLHttpRequest();
        } else {          
            xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
        } 
  xmlhttp.onreadystatechange=function() 
   {
    if (this.readyState==4 && this.status==200) 
	{
     	if(this.responseText==1)
     	{
     		if(ops==1){
     			alert("New pincode generated successfully");
     			window.location.href = ("addPincode.php");
     		}
     		else
     		{
     			alert("New pincode has been updated successfully");
     			window.location.href = ("addPincode.php");
     		}
     		
     	}
     	else if(this.responseText==2)
     	{	if(ops==1){
     		alert("Pincode is already exist | Try new pincode");
     		window.location.href = ("addPincode.php");
     		}
     		else 
     		{
     			alert("This pincode is already exist | Can not update the pincode | Try new pincode");
     		    window.location.href = ("addPincode.php");
     		}

     	}
     	else if(this.responseText==0)
     	{
     		if(ops==1){
     			alert("Failed to generate new pincode");
     			window.location.href = ("addPincode.php");
     		}
     		else
     		{
     			alert("Failed to update new pincode");
     			window.location.href = ("addPincode.php");
     		}
     		
     	}
	}
  };
  if(ops==1){
  xmlhttp.open("GET","saveNewPincode.php?newpin="+newpin+"&pin_status="+pin_status,true);
  xmlhttp.send();
}
else
{
	var psr=$("#psr").val();
	xmlhttp.open("GET","updateNewPincode.php?newpin="+newpin+"&pin_status="+pin_status+"&psr="+psr,true);
  xmlhttp.send();
}

}