Check if a node has number value - Node.js DOM

Node.js examples for DOM:Node

Description

Check if a node has number value

Demo Code


  isNumber : function(s, d) {
    return !isNaN(s.nodeType == 1 ? s.value : s) && (!d || !this.test(s, '^-?[0-9]*\\.[0-9]*$'));
  },//from ww w  .j  ava  2 s.co m

  test : function(s, p) {
    s = s.nodeType == 1 ? s.value : s;

    return s == '' || new RegExp(p).test(s);
  }

Related Tutorials