How to use JQuery Custom validation method to validate phone number

How to use JQuery Custom validation method to validate phone number

I wanted to validate a phone number using jQuery custom validation method.I tried to write a method for that but it didn't work .Can anyone help me to find the error of this code .As I'm new to this language I don't know much about jQuery. here is my code


  1. $(document).ready(function () {

  2. jQuery.validator.addMethod('phonenu', function(value, element) {
  3.     if(element.value != 10 && element.value == isNaN)
  4.     {
  5.         return false;
  6.     }
  7.     else 
  8.     {    return true;
  9.         
  10.     }, 'Invalid phone number'}); 


  11.     $('#myform').validate({
  12.         rules: {
  13.             phone: {
  14.                 required: true
  15.                 phonenu: true,
  16.                 
  17.             }
  18.         }
  19.     });

  20. });
html code 
  1. <form id="myform">
  2.     <input name="phone" type="text" />
  3.     <input type="submit" />
  4. </form>