diff --git a/script/eventos.js b/script/eventos.js index abf3f62..80c3e3d 100644 --- a/script/eventos.js +++ b/script/eventos.js @@ -31,10 +31,10 @@ const sendData = (form) => { request.onreadystatechange = function() { if (this.readyState == 4 && this.status == 200) { - alert(this.responseText) + finish(this.responseText) } else if(this.readyState >= 4) { - alert('ERRO: ' + this.responseText) + finish('ERRO: ' + this.responseText) } } @@ -58,6 +58,7 @@ const sendData = (form) => { } + const validator = (formData) => { if(formData.get("titulo").length < 5) { @@ -80,19 +81,31 @@ const validator = (formData) => { } + +const finish = (text) => { + openCloseModal('none') + alert(text) + window.location.reload() +} + + + const openCloseModal = (acao) => { document.getElementsByClassName('modal-content')[0].style.display = acao document.getElementsByClassName('form')[0].style.display = acao } + const numberMask = (element) => { element.value = element.value.replace(/\D/g,'') } + + const currencyMask = (element) => { var v = element.value.replace(/\D/g,'') v = (v/100).toFixed(2) + '' v = v.replace(".", ",").replace(/(\d)(?=(\d{3})+(?!\d))/g, '$1.') element.value = v -} \ No newline at end of file +}