Please help me create a JavaScript function that can determine if the text in a textbox is a number. If it's not a number, I would like the function to focus on the textbox and change the format to look like this (xx-xxxxxx) when numbers are typed in, such as (12-123456). I am new to JavaScript and could use some guidance.
Here is what I have so far:
function checkNumber(elem)
{
if(Number.isInteger(elem))
{
// To validate the format(xx-xxxxxx)
}
else
{
elem.focus();
}
}