I need to check and make sure that a variable contains ONLY numerals 0-9 or a period or a comma. Anything else should be rejected.
I've set up a simple IF statement in a function that I thought would work but it's not:
function numCheck(source) {
if (!(source.matches("[0-9.,]*"))) {
alert('Number');
}
else {
alert('Not a number');
}
}
Nothing happens. I can call the function without the if statement and it works, but somehow I'm just not correctly doing the syntax.