Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function init(){
- setInputFilter( document.getElementById( "txt_nrc" ), function(value) {
- return /^\d*\.?\d*$/.test(value);
- } );
- }
- function agregarDatos(){
- var datos = document.getElementById( "tabladatos" );
- datos.innerHTML += "<tr>"
- + "<td>" + document.getElementById( "txt_nrc" ).value + "</td>"
- + "<td>" + document.getElementById( "txt_curso" ).value + "</td>"
- + "<td>" + document.getElementById( "cmb_horario" ).value + "</td>"
- + "<td>" + document.getElementById( "chk_estado" ).value + "</td>"
- + "<td>" + document.querySelector( 'input[ name=rdb_tipo ]:checked' ).value + "</td>"
- + "</tr>"
- }
- function setInputFilter(textbox, inputFilter) {
- ["input", "keydown", "keyup", "mousedown", "mouseup", "select", "contextmenu", "drop"].forEach(function(event) {
- textbox.addEventListener(event, function() {
- if (inputFilter(this.value)) {
- this.oldValue = this.value;
- this.oldSelectionStart = this.selectionStart;
- this.oldSelectionEnd = this.selectionEnd;
- } else if (this.hasOwnProperty("oldValue")) {
- this.value = this.oldValue;
- this.setSelectionRange(this.oldSelectionStart, this.oldSelectionEnd);
- } else {
- this.value = "";
- }
- });
- });
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement