mercredi 20 juin 2018

regular expression for (000)000-0000 not working?

Regular expresson not working properly but it works for other regex like /.*/

if(value == 'phone'){
     if(this.get('user.phone').length>0){
      if (( /^\(\d{3}\)\s\d{3}-\d{4}$/.test(this.get('user.phone'))) ){
        const user_obj = {
            phone: this.get('user.phone'),
            sessionid: localStorage.getItem('session_id'),
        }
        set(this, 'pass_user', user_obj);
        this.set('invalidPhone', false);
      }
      else{
        this.set('invalidPhone', true);
      }     
    }
    else{
      this.set('invalidPhone', false);
    }
  }




Aucun commentaire:

Enregistrer un commentaire