-2

I am trying to validate a phone number with the international validations. I am working on the french one currently. Here is what I have, it's not working. Any suggestions

<html>
<head>

</head>
<body>
<form id="myFormId" method="post">
    <label for="phoneId">Phone number</label>
    <input type="text" name="phone" id="phoneId" maxlength="19" value="" />

    <input type="submit" value="Submit" onClick="isValidPhonenumber()"/>
</form>

    <script>
function isValidPhonenumber(value) {
    return (/^\d{7,}$/).test(value.replace(/[\s()+\-\.]|ext/gi, ''));
}
</script>
</body>
</html>
ryanh
  • 9
  • 2
  • What's exactly "not working"? Do you have test cases? – Pavlo Aug 21 '14 at 15:13
  • https://www.dropbox.com/s/67624j6gxox5uj6/Screenshot%202014-08-21%2011.57.12.png thank you for your hard work in researching this problem before asking! – djechlin Aug 21 '14 at 15:56

1 Answers1

0

It is probably best to provide, the errors. However, I can see onClick="isValidPhonenumber()" is not taking in a value like your function, which will result in an error. You probably should do document.getElementById('phoneId') in the function and take the parameter "value" out of your function.

Rika
  • 768
  • 1
  • 5
  • 16