customd / jquery-number

Easily format numbers for display use. Replace numbers inline in a document, or return a formatted number for other uses.
https://www.customd.com/articles/14/jquery-number-format-redux
MIT License
442 stars 402 forks source link

OnKeyUp event in a input type=text #65

Open joivan opened 10 years ago

joivan commented 10 years ago

Hi, i have this event in my input and the onKeyUp event is in conflict with the number class of yours function number.

joivan commented 10 years ago

input name="prec_rep" id="prec_rep" type="text" class="validate[required] numero2" onKeyUp ="mostrar_formulario_dinamico('frm_compara_precio_reporto',{'xid':<?php echo $_REQUEST['tid_emis']; ?>,'valor':$('#prec_rep').val(),'tasan':<?php echo $_REQUEST['tasanominal'];?>,'fecha':$('#campofecha3').val()},'val_reporto'); calcula_prec_total(); return false;"

samatcd commented 10 years ago

Ok, this key up event handler will override or execute before the jQuery number event handler.

If you split that JavaScript out of the HTML, and use jQuery to bind the event after the jQuery number plugin is initialised, it should work just fine.

E.g., $('#prec_rep').number(true); // Add your currency format parameters as required.

$('#prec_rep').on('keyup',function(){ /** Your onKeyUp code here **/ });
joivan commented 10 years ago

Hi, thanks for the answer i did this change in my code and the result doesn't works the problem is the same both functions are override when execute the onKeyUp

samatcd commented 10 years ago

Could you post a jsfiddle example of the issue?