I currently have a phone number validation script that has been written in JavaScript, What I am looking to do is translate my code from JavaScript to PHP as the rest of the website does all validations once submitted in PHP.
The format rules should be as follows: 1st and 2nd number must be 0 n 3 respectively. and 3rd number can be either 0,1,2,3, or 4
<script>
function validation(){
var a = document.getElementById("contact").value;
if((a.charAt(0)!=0) || (a.charAt(1)!=3) || ((a.charAt(2)!=0) && (a.charAt(2)!=1)&& (a.charAt(2)!=2) && (a.charAt(2)!=3) && (a.charAt(2)!=4)))
{
document.getElementById("message").innerHTML="Contact number is invalid.";
return false;
}
}
</script>