Alert if variable contains non numeric characters?

javascript, regex

Solution

if (p.match(/[^$,.\d]/))
    alert('error!');

Live DEMO

You can use this Excellent regex cheat sheet.

Problem

'p' can only store "$", commas, dots or numbers. How can I show an alert if it contains any other character?

Original source