I gave the input (123,456.12)
and my output should be -123456.12
. But its coming as just -123
. I used the expression:
enteredValue = window.event.srcElement.value.replace(/^[-(]\D*([\d.]+).*$/gm, '-$1')
Please help.
Try
var str = "(123,456.12)".replace( /[(),]/g, "" );
var num = -Number( str );
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.