Hi.
I have a problem with some JS at my website.
The user has to fill out a form, enter his/her name, e-mail, phonenumber, location etc.
The problem is that I don't want to have a fake phonenumber entered to my database, so I want to verify the phonenumber by comparing the area codes of my country (Sweden).
I have all the area codes, (2, 3 or 4 digits) but dont know how to take the entered value and see if the first characters matches the area codes.
function validateForm() {
var msg = "Check:\n\n";
var name=document.forms["quest"]["name"].value
if (name==null || name==""){
msg += " - Name\n";
}
var tele=document.forms["quest"]["tele"].value
var telelangd = tele.length;
if (tele==null || tele=="" || isNaN(tele) || telelangd < 8)
msg += " - Telephonenumber\n";
//continues with e-mail etc...
msg = A warning message. If the user types something wrong, it will show when msg is alerted after clicking the "check" button.
Tried to understand startWith(), but it failed.
Can anyone help me?