Advertisement
Guest User

Untitled

a guest
Feb 17th, 2020
75
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.26 KB | None | 0 0
  1. function init(){
  2. setInputFilter( document.getElementById( "txt_nrc" ), function(value) {
  3. return /^\d*\.?\d*$/.test(value);
  4. } );
  5. }
  6.  
  7. function agregarDatos(){
  8. var datos = document.getElementById( "tabladatos" );
  9. datos.innerHTML += "<tr>"
  10. + "<td>" + document.getElementById( "txt_nrc" ).value + "</td>"
  11. + "<td>" + document.getElementById( "txt_curso" ).value + "</td>"
  12. + "<td>" + document.getElementById( "cmb_horario" ).value + "</td>"
  13. + "<td>" + document.getElementById( "chk_estado" ).value + "</td>"
  14. + "<td>" + document.querySelector( 'input[ name=rdb_tipo ]:checked' ).value + "</td>"
  15. + "</tr>"
  16. }
  17.  
  18. function setInputFilter(textbox, inputFilter) {
  19. ["input", "keydown", "keyup", "mousedown", "mouseup", "select", "contextmenu", "drop"].forEach(function(event) {
  20. textbox.addEventListener(event, function() {
  21. if (inputFilter(this.value)) {
  22. this.oldValue = this.value;
  23. this.oldSelectionStart = this.selectionStart;
  24. this.oldSelectionEnd = this.selectionEnd;
  25. } else if (this.hasOwnProperty("oldValue")) {
  26. this.value = this.oldValue;
  27. this.setSelectionRange(this.oldSelectionStart, this.oldSelectionEnd);
  28. } else {
  29. this.value = "";
  30. }
  31. });
  32. });
  33. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement