Javascript手机验证无法正常工作

时间:2016-09-19 12:27:15

标签: javascript php materialize

我有这个用于验证手机的JavaScript代码。但我已经尝试过所有可能的事情都没有成功。我的日期选择器验证也无效。

这是我的代码段

import {Component} from 'angular2/core';
@Component({
    selector: 'my-app',
    template:`
navigator.onLine
{{onlineFlag}}

`
})
export class AppComponent {
  public onlineFlag =navigator.onLine;
}

2 个答案:

答案 0 :(得分:0)

在parseInt下面使用

if(parseInt(phone) != phone)
{
alert("Enter the valid Mobile Number(Like : 9566137117)");
document.form.phone.focus();
return false;
}

答案 1 :(得分:0)

用户模式属性 -



<form id="form">
<input type="tel" pattern="[0-9]{10}">
  <input type="submit">
  </form>
&#13;
&#13;
&#13;