function verifyNumber(value) { let reg = /^[+]{0,1}(d+)$|^[+]{0,1}(d+.d+)$/; let lastChar = value.substr(value.length - 1); return reg.test(lastChar) || value === ""; } verifyNumber("-1") //true verifyNumber("+1") //true verifyNumber("1") //true verifyNumber("1a") //false