3

I can check the validation of the number, How can I change to string in the same function?

hasValidPhone: function() {
    var isValidPhone = /^\+?[\d-|,|]{7,15}$/.test(this.val());
    return this.length > 0 ? isValidPhone : false;
},
shma1001
  • 31
  • 1
  • 4

3 Answers3

2

You can do the following

var n = 14;
n.toString();

or

var n = String(14);

or

var n = 14+"";
Mazz
  • 1,859
  • 26
  • 38
1
var yourVar = String(this.val());
0

You can simply toSring function like this -

var num = 15;
var n = num.toString(); 
shv22
  • 680
  • 5
  • 28
  • Is there any way to be able to send you the code so you can help me? I am very new in this /Thanks – shma1001 Feb 10 '17 at 14:20
  • @shma1001 dude just when you get the number you just make it is as a string like say isValidPhone is your when you get it now just do isValidPhone .toString(); thats it – shv22 Feb 13 '17 at 04:37