Created
July 20, 2017 19:39
-
-
Save igoralves1/fa314a61c668a00f5d3b1f1fa1e90bc6 to your computer and use it in GitHub Desktop.
Validation regex Javascript
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| function validateRefund(el) { | |
| reg = /^[1-9][0-9]*(\.[0-9]{1,2})?$/; | |
| if (!reg.test(el.value)) | |
| return false; | |
| if (parseFloat(el.value) > parseFloat($(el).data('max')) || parseFloat(el.value) <= 0) { | |
| return false; | |
| } else { | |
| return true; | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment