1

i have a problem with format number in Struts 2 Java EE.

I get a double from de DataBase for example 1000,3 but , when i try to print this value in the textfield .... , this value show like this 1.000,3 witch de dot, and i want to show the number with-out the dot . Thx.

<td> <s:textfield name="example[%{#stat.index}].Import" id="Import%{#stat.index}" onBlur="Validate(this)"/>

Validate is only a JavaScript function witch Regex thx.

Roman C
  • 49,761
  • 33
  • 66
  • 176
Prokaz
  • 11
  • 1
  • What type is your `example[%{#stat.index}].Import`? It is probably your js function problem try to remove it. – Aleksandr M Oct 16 '15 at 08:46
  • example[%{#stat.index}].Import its a Double , js its ok its only this function Validate(object){ var RegExPattern =/^\d{1,6}(\,\d{2})?$/; var RegExPattern2 =/^\d{1,6}(\,\d{1})?$/; var campo=object.value; if(!campo.trim().match(RegExPattern)){ if(!campo.trim().match(RegExPattern2)){ alert("formato de precio no válido. Formato aceptado '0,00'"); object.value=""; object.focus(); } } – Prokaz Oct 16 '15 at 09:47
  • I debug the program and all double variable in action or BaseDate are ok , the problem its only in struts 2 in the textfield :S – Prokaz Oct 16 '15 at 10:02
  • Format a number as explained http://stackoverflow.com/a/23084580/573032 – Roman C Oct 17 '15 at 08:17

0 Answers0