Skip to content

Commit

Permalink
Merge pull request #4 from m0nt4ld0/dev
Browse files Browse the repository at this point in the history
Valida campos (sólo letras)
  • Loading branch information
m0nt4ld0 authored Aug 18, 2024
2 parents ac69dbb + ccb8773 commit f8b932f
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion scripts/crossword-puzzle.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,10 @@ function preloadCrossword() {

// Dibujar el crucigrama
function drawCrossword (vword, ans, showAnswers) {
let html = '<form><table class="table table-borderless">';
let html = `
<form>
<table
class="table table-borderless">`;

// i es contador para cantidad de letras de la palabra vertical (filas del crucigrama)
for(i=0; i < ans.length; i++) {
Expand Down Expand Up @@ -114,6 +117,11 @@ function setCrosswordReferences(descriptions, container) {
function validateChar(i, c) {
const txtName = 'txt-' + i + '-' + c ;
const e = document.getElementById(txtName);
const esLetra = /^[A-Za-z]$/;
if (!esLetra.test(c)) {
e.value = '';
return;
}
if(e.value.toUpperCase() != _answers[i][c].toUpperCase()) {
e.classList.remove("correct-answer");
e.classList.add("wrong-answer");
Expand Down

0 comments on commit f8b932f

Please sign in to comment.