unioil-loyalty-rn-app/app/utils/number.js

13 lines
434 B
JavaScript

export const checkPhoneNumberInput = (num) => {
const numbReg = /^[0-9]+$/;
const newValue = num.replace("+63", "");
//Check if value is not number.
if(newValue.length > 0 && !numbReg.test(newValue)) return false;
//Check if valus starts with number 9.
//0 is allowed to be the first number for demo porposes.
if(newValue.length > 0 && !newValue.startsWith("9")) return false;
return true;
}