I need to validate Australian number so it can only accept this formate
+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]+)?)$
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.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.