troubleshooting Question

Numeric/Money Validation, My function is not working as expected

Avatar of Westside2004
Westside2004Flag for United States of America asked on
3 Comments1 Solution1123 ViewsLast Modified:

I have this function that sort of works.  It validates this field where I want users to type in a "dollar" amount.

function isMoney(elm) {
    str = elm.replace("$", "");
     str = str.replace(",","");      //regex=/^[a,b,c,x,y,z]{3}\d{3}$/;
     var myexp = /^\d+\.\d{0,2}$/;
     var regex = new RegExp(myexp);
     return regex.test(str);

This works fine


This does not


Is there a way to have it so if the user enters just  34 it will add the .00  if it does NOT exist already.

My database has a column with a datatype of Money (using sql server).



Our community of experts have been thoroughly vetted for their expertise and industry experience.

Join our community to see this answer!
Unlock 1 Answer and 3 Comments.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 3 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros