It is better to do it in javascript first, then in php (php is safer)...
To the input-field of the longditude add: onchange="checkLongitude(this)", then on the input-field of the latitude add: onchange="checkLatitude(this)".
Then add this code:
<script language="javascript">
function checkLongitude(field)
{
var error = false;
if(isNumeric(field.value))
{
if(!((!(field.value < 180)) && (!(field.value > -180))))
{
error = true;
}
}
else
{
error = true;
}
if(error)
{
field.value = "";
field.focus();
alert("Longitude range is -180.00 to 180.00");
}
}
function checkLatitude(field)
{
var error = false;
if(isNumeric(field.value))
{
if(!((!(field.value < 90)) && (!(field.value > -90))))
{
error = true;
}
}
else
{
error = true;
}
if(error)
{
field.value = "";
field.focus();
alert("Latitude range is -90.00 to 90.00");
}
}
function isNumeric(variable)
{
var ValidChars = "0123456789.";
var IsNumber = true;
var Char;
for (i = 0; i < sText.length && IsNumber == true; i++)
{
Char = sText.charAt(i);
if (ValidChars.indexOf(Char) == -1)
{
IsNumber = false;
}
}
return IsNumber;
}
</script>