0
[<input id=​"unit_quantity_0" name=​"lines[0]​[quantity]​" placeholder=​"Quantité" type=​"text" value=​"23,60">​
,<input id=​"unit_quantity_2" name=​"lines[2]​[quantity]​" placeholder=​"Quantité" type=​"text" value=​"5,60">​]

How do I change the ',' in values to '.'

$("[id^=unit_quantity_]") returns the array.

Thanks.

isherwood
  • 58,414
  • 16
  • 114
  • 157
Laura
  • 4,199
  • 6
  • 23
  • 24

2 Answers2

3

How about:

$("[id^='unit_quantity_']").val(function (i, old) {
    return old.replace(/,/g, ".");
});

Example: http://jsfiddle.net/andrewwhitaker/325We/

Using the overload of .val that takes a function that lets you describe how to replace the old values.

Andrew Whitaker
  • 124,656
  • 32
  • 289
  • 307
0
$("[id^=unit_quantity_]").each(function(){
    var $this=$(this);
    $this.val( $this.val().replace(/,/g,'.'));
});
charlietfl
  • 170,828
  • 13
  • 121
  • 150