jQuery validate plugin - currency

前端 未结 1 1827
情书的邮戳
情书的邮戳 2021-01-27 15:49

I am attempting to figure out how to validate a number in the jQuery validate plugin as legitimate US currency, max two decimal place zeroes, without commas or dollar signs (250

1条回答
  •  深忆病人
    2021-01-27 16:00

    I am attempting to figure out how to validate a number in the jQuery validate plugin as legitimate US currency, max two decimal place zeroes, without commas or dollar signs (25000.00, 1.00 , etc)

    Simply include the additional-methods.js file and use the built-in currency method as follows...

    currency: ["$", false] // dollar sign optional
    
    currency: "$" // dollar sign required (default)
    

    Note: commas are optional in all cases.

    DEMO: http://jsfiddle.net/d4ywy0fu/2/


    NOTE: Your jsFiddle also contains a DOM ready handler inside of another DOM ready handler. While it's not harmful, it's totally superfluous.

    $(function() {  // <- DOM Ready Handler
    
        $(document).ready(function() {  // <- DOM Ready Handler
            ....
    

    0 讨论(0)
提交回复
热议问题