简体   繁体   English

angular 中没有 0 的澳大利亚号码验证

[英]Australian number validation without 0 in angular

I need to validate Australian number so it can only accept this formate我需要验证澳大利亚号码,所以它只能接受这个甲酸盐

+61410029026 +61410029026

Currently what i have done目前我做了什么

<div class="form-group login-input">
  <label for="mobilenumber " class="numberfixdigite">+61</label>
    <input type="text" oninput="this.value = this.value.replace(/[^0-9.]/g, '').replace(/(\..*?)\..*/g, '$1');" formControlName="phone_number" class="form-control" minlength="9" maxlength="12" name="phone" id="mobilenumber" placeholder="Phone number" required="" control-id="ControlID-4">
      <span style="color:red">Please enter mobile like 4xx 8xx 5xx</span>
        <div *ngIf="fh.check(g['phone_number'], f)" class="errors">
           <p *ngIf="g['phone_number'].errors">Mobile is required</p>
        </div>
 </div>

Try This尝试这个

^((?:[1-9][0-9]*)(?:.[0-9]+)?)$ ^((?:[1-9][0-9]*)(?:.[0-9]+)?)$

I would use this:我会用这个:

/^\+61[4,8,5]{1}[0-9]{7}$/

and before checking if regex matches, you could have a check if the user added the country code, if not, you could add it and then check the regex.在检查正则表达式是否匹配之前,您可以检查用户是否添加了国家代码,如果没有,您可以添加它然后检查正则表达式。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM