Skip to content

Commit

Permalink
Blanquea el casillero si el usuario intenta escribir algo que no sea …
Browse files Browse the repository at this point in the history
…una letra
  • Loading branch information
m0nt4ld0 committed Aug 18, 2024
1 parent f722b47 commit ccb8773
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 ccb8773

Please sign in to comment.