Trying to write a javascript regex for forcing users to enter decimal after a whole number, doesn't seem like many people want to do this as my searches have yielded nothing that suits my needs.
Match: 2.00 20.00 200.00 1.73 0.10
No Match: .2 .20 . 1 10 1.0 0.1 1.
Here is what I have currently:
var regexp=/^[0-9]{1,}\.{1}[0-9]{2}$/;
In plain english, users must enter money in X.XX format. Just a whole number by itself is disallowed.
I'd appreciate any help and also teaching insight anyone has to offer in making this work.
EDIT:
Here is code:
var notempty=/[a-zA-Z0-9\.\$]/g;
var money=/^[0-9]{1,}\.{1}[0-9]{2}$/;
if ( (notempty.test(document.getElementById('numbers').value)) && (!money.test(document.getElementById('numbers').value)) )
{alert('Wrong format');}