Home > OS >  Australian number validation without 0 in angular
Australian number validation without 0 in angular

Time:01-06

I need to validate Australian number so it can only accept this formate

61410029026

Currently what i have done

<div >
  <label for="mobilenumber " > 61</label>
    <input type="text" oninput="this.value = this.value.replace(/[^0-9.]/g, '').replace(/(\..*?)\..*/g, '$1');" formControlName="phone_number"  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)" >
           <p *ngIf="g['phone_number'].errors">Mobile is required</p>
        </div>
 </div>

CodePudding user response:

Try This

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

CodePudding user response:

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.

  • Related