After I move the JS code out of HTML into a file, the function stop working and I have no idea why this happen,
Here is the html code,
<head>
<script src="foo.js"></script>
...
<form ... onsubmit="return check(this)">
//////////////////////////////
//////////////////////////////
here is the js code:
function check_long(field, txt){
with (field){
if(!valeu || value < -180 || value > 180){
alert(txt);
return false;
}
else {return true;}}}
function check_lat(field, txt){
with(field){
if (!value || value < -90 || value > 90){
alert(txt);
return false;
}
else {return true;}}}
function check(form){
with (form){
if (check_long(longitude,"not a valid longitude!") == false){
longitude.focus();
return false;
}
if (check_lat(latitude, "not a valid latitude!") == false){
latitude.focus();
return false;
}}}
(this code working fine when inside the HTML file)
THank you for any suggestion.
Here is the html code,
<head>
<script src="foo.js"></script>
...
<form ... onsubmit="return check(this)">
//////////////////////////////
//////////////////////////////
here is the js code:
function check_long(field, txt){
with (field){
if(!valeu || value < -180 || value > 180){
alert(txt);
return false;
}
else {return true;}}}
function check_lat(field, txt){
with(field){
if (!value || value < -90 || value > 90){
alert(txt);
return false;
}
else {return true;}}}
function check(form){
with (form){
if (check_long(longitude,"not a valid longitude!") == false){
longitude.focus();
return false;
}
if (check_lat(latitude, "not a valid latitude!") == false){
latitude.focus();
return false;
}}}
(this code working fine when inside the HTML file)
THank you for any suggestion.