Created
June 28, 2018 19:43
-
-
Save RobertoCGarcia/417a1501f7323c5099454cdbeb11001a to your computer and use it in GitHub Desktop.
Validación de Campos JavaScript Para WebForm de Drupal 8 - Código Probado para agregar una validación via custom js a los campos generados por el módulo webform de Drupal 8.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function validateCaptcha(){ | |
var valueGr = document.getElementById("g-recaptcha-response").value; | |
if(valueGr == null){ | |
return false; | |
}else{ | |
return true; | |
} | |
} | |
$(document).ready(function () { | |
console.log("Entra a validacion de Formulario de Webform"); | |
jQuery("#edit-telefono-cliente").on('input', function (event) { | |
this.value = this.value.replace(/[^0-9]/g, ''); | |
console.log("Validacion edit-telefono-cliente"); | |
}); | |
jQuery("#edit-telefono-celular-cliente").on('input', function (event) { | |
this.value = this.value.replace(/[^0-9]/g, ''); | |
console.log("Validacion edit-telefono-celular-cliente"); | |
}); | |
jQuery("#edit-nombre-cliente").on('input', function (event) { | |
this.value = this.value.replace(/[^a-zA-Z\s]/g, ''); | |
console.log("Validacion edit-nombre-cliente"); | |
}); | |
jQuery("#edit-apellidos-cliente").on('input', function (event) { | |
this.value = this.value.replace(/[^a-zA-Z\s]/g, ''); | |
console.log("Validacion edit-apellidos-cliente"); | |
}); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment