Sometimes we need to check the string type. Here we will learn how to check the string is Number. to check the string we can make the one function in a common file.
Place the below function in your js file.
function isNumber(text){
if(text) {
var reg = new RegExp('[0-9]+$');
return reg.test(text);
}
return false;
}
console.log(isNumber(21323))
way to call the isNumber
function.
console.log(isNumber(21323))
Output:-
true
Hello Friends, I’m Mohit Sharma founder of tutrialwala.com, Full Stack Web Developer. Expertise in WordPress, PHP, Laravel, Angular, and Frontend Development. In this publication, I share everything I know about PHP frameworks and Javascript frameworks, packages, and tools.
Have a project in mind? Get in touch