<script language="javaScript">
function personal()
{
if (document.post1.fname.value=="")
{
alert("You have to enter your first name!");
return false;
} else if (document.post1.lname.value=="")
{
alert("You have to enter your last name!");
return false;
} else if (document.post1.city.value.length<3)
{
alert("The name of the city where you live cannot be less than 3 characters!");
document.post1.city.focus();
return false;
} else if (!/^\d{10}$/.test(document.post1.mobile.value)){
alert("...");
document.post1.mobile.focus();
return false;
}
return true;
}
</script>
Frågan#1
Har denna kod:
<script language="javaScript">
function personal()
{
if (document.post1.fname.value=="")
{
alert("You have to enter your first name!");
return false;
} else if (document.post1.lname.value=="")
{
alert("You have to enter your last name!");
return false;
} else if (document.post1.city.value.length<3)
{
alert("The name of the city where you live cannot be less than 3 characters!");
document.post1.city.focus();
return false;
}
}
</script>
Vill lägga till så att den kollar ett fält (mobile) så att det bara innehåller nummer. Hur gör jag det?