-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscript.js
More file actions
42 lines (35 loc) · 1.39 KB
/
Copy pathscript.js
File metadata and controls
42 lines (35 loc) · 1.39 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
const criptoBtn = document.getElementById("btn-cripto");
const descriptoBtn = document.getElementById("btn-descripto");
const msg = document.getElementById("msg-text");
const copyBtn = document.getElementById("btn-copy");
let input = document.getElementById("input-text");
function copiar() {
let msgTxt = msg.value
navigator.clipboard.writeText(msgTxt);
document.getElementById("copiado").innerText = "Copiado!"
setTimeout(function(){
document.getElementById("copiado").innerHTML = '';
}, 400);
}
function validarCripto() {
let inputTxt = input.value;
let regex = /^[a-z0-9 ,.!?;:()]+$/g;
let validacao = regex.test(inputTxt)
if (validacao == true) {
let criptoTxt = inputTxt.replace(/e/g, "enter").replace(/i/g, "imes").replace(/a/g, "ai").replace(/o/g, "ober").replace(/u/g, "ufat");
return msg.innerText = criptoTxt
} else {
return alert ("Apenas letras minúsculas, sem acentos e caracteres especiais")
}
}
function validarDescripto() {
let inputTxt = input.value;
let regex = /^[a-z0-9 ,.!?;:()]+$/g;
let validacao = regex.test(inputTxt)
if (validacao == true) {
let descriptoTxt = inputTxt.replace(/enter/g, "e").replace(/imes/g, "i").replace(/ai/g, "a").replace(/ober/g, "o").replace(/ufat/g, "u");
return msg.innerText = descriptoTxt
} else {
return alert ("Apenas letras minúsculas, sem acentos e caracteres especiais")
}
}