0
votes

I have the latest version of telerik (2013) but I am with the following problem, I need to change the value of a radnumerictextbox using javascript (client side), but after I set a value using JQuery or javascript regular control changes value because daa format, follows the control and js code:

    <telerik: RadNumericTextBox id = "txtValor" runat = "server" EnableEmbeddedSkins = "false" Height = "15px" Skin = "Corporate" Width = "90%">
        <NumberFormat DecimalSeparator="," DecimalDigits="2" />
    </ telerik:RadNumericTextBox>

I try this

       $(idCampo).val(_valorTotal.replace(".", ","));
       $(nomeCampo).text(_valorTotal.replace(".", ","));

when running a postback the mask is lost, for example: 2000.55 = 200,055.00

And also tried this:

      $(idCampo).val(parseFloat (_valorTotal));
      $(idCampo).text(_valorTotal.replace (".", ""));

when executed the value is shown without masks, but when generated the postback event is placed usually 2000.55 = 2.000,55

Would have some event to update fields in the mask? Would otherwise not have tried to set a value in control?

1

1 Answers

-1
votes

you need a function java script use my script :)

function Moneda(formato) {
    var num = formato;//parseFloat("40000.51239");
    var cadena = ""; var aux;  
    var cont = 1,m,k;  
    if(num<0) aux=1; else aux=0;  
    num=num.toString();    

    for(m=num.length-1; m>=0; m--){  
        cadena = num.charAt(m) + cadena;  
        if(cont%3 == 0 && m >aux)  cadena = "." + cadena; else cadena = cadena;  
        if(cont== 3) cont = 1; else cont++;  
    }  

    cadena = cadena.split(".").join(",");  
    var separacion = "";
    var quitarDobleComa = cadena.search(",,");
    separacion = cadena.substring((quitarDobleComa+2),cadena.length); 
    separacion = separacion.split(",").join("");   
    var formatoPunto = cadena.substring(0,quitarDobleComa); 
    var final = formatoPunto +"."+ separacion;
    return final;
}