Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Javascript Split/Join Or Replace spaces globally

I am running outta my mind now, can someone please explain what is happening here:

Screenshot

Why's the same JS function producing different results?

Here's the actual HTML:

<input id="xamount" data-pr-xamount="1" value="R 5 700,00" placeholder="Enter Amount" style="width: 88%;" class="valid" type="text">
like image 254
Morgs Avatar asked Feb 05 '23 14:02

Morgs


2 Answers

Those spaces may not be traditional spaces, try splitting on actual white-space:

/\s+/

In your case:

$('[data-pr-xamount="1"]').last().val().split(/\s+/);
like image 139
KevBot Avatar answered Feb 08 '23 03:02

KevBot


There must be a character different than a space between 5 and 7.

like image 31
Constantin Harabara Avatar answered Feb 08 '23 04:02

Constantin Harabara