-
-
Save bendasvadim/89ac1ee6a1ec0d03734d03731be14a99 to your computer and use it in GitHub Desktop.
check sum input
This file contains 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
this.value = sum(this.value); | |
function sum(str) { | |
str=str.trim().replace(/[^\d\.]+/gi,""); | |
var s=str.indexOf(".",str.indexOf(".")); | |
if(s>=0){ | |
str=str.substr(0,s+3); | |
var whole = str.substr(0,s); | |
var fractional = str.substr(s+1, s+3).replace(/[^\d]+/gi,""); | |
str = whole +'.'+ fractional; | |
} | |
return str | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment