1882
| <![CDATA[<script>
$(function(){
$("#enviar").click(function(){
if(grecaptcha && grecaptcha.getResponse().length == 0) {
alert('Oops, precisamos ter certeza que você não é um rôbo !');
return false;
}
})
})
function check1(checkbox) {
var checkboxes = document.getElementsByName('declaro')
checkboxes.forEach((item) => {
if (item !== checkbox) item.checked = false
})
}
function check2(checkbox) {
var checkboxes = document.getElementsByName('horario')
checkboxes.forEach((item) => {
if (item !== checkbox) item.checked = false
})
}
function check3(checkbox) {
var checkboxes = document.getElementsByName('publicidade')
checkboxes.forEach((item) => {
if (item !== checkbox) item.checked = false
})
}
var currentDate = new Date(),
currentDay = currentDate.getDate() < 10
? '0' + currentDate.getDate()
: currentDate.getDate(),
currentMonth = currentDate.getMonth() < 9
? '0' + (currentDate.getMonth() + 1)
: (currentDate.getMonth() + 1);
document.getElementById("data").innerHTML = currentDay + '/' + currentMonth + '/' + currentDate.getFullYear();
function verificaExtensao($input) {
var extPermitidas = ['jpg', 'png', 'pdf'];
var extArquivo = $input.value.split('.').pop();
if(typeof extPermitidas.find(function(ext){ return extArquivo == ext; }) == 'undefined') {
alert('Extensão "' + extArquivo + '" não permitida!');
return false;
} else {
// alert('Ok!');
}
}
//$(document).on("input", "#metragem", function (e) {
// this.value = this.value.replace(/[^0-9.]/g, '').replace(/(\..*)\./g, '$1');
//});
function handleNumber(event, mask) {
/* numeric mask with pre, post, minus sign, dots and comma as decimal separator
{}: positive integer
{10}: positive integer max 10 digit
{,3}: positive float max 3 decimal
{10,3}: positive float max 7 digit and 3 decimal
{null,null}: positive integer
{10,null}: positive integer max 10 digit
{null,3}: positive float max 3 decimal
{-}: positive or negative integer
{-10}: positive or negative integer max 10 digit
{-,3}: positive or negative float max 3 decimal
{-10,3}: positive or negative float max 7 digit and 3 decimal
*/
with (event) {
stopPropagation()
preventDefault()
if (!charCode) return
var c = String.fromCharCode(charCode)
if (c.match(/[^-\d,]/)) return
with (target) {
var txt = value.substring(0, selectionStart) + c + value.substr(selectionEnd)
var pos = selectionStart + 1
}
}
var dot = count(txt, /\./, pos)
txt = txt.replace(/[^-\d,]/g,'')
var mask = mask.match(/^(\D*)\{(-)?(\d*|null)?(?:,(\d+|null))?\}(\D*)$/); if (!mask) return // meglio exception?
var sign = !!mask[2], decimals = +mask[4], integers = Math.max(0, +mask[3] - (decimals || 0))
if (!txt.match('^' + (!sign?'':'-?') + '\\d*' + (!decimals?'':'(,\\d*)?') + '')) return
txt = txt.split(',')
if (integers && txt[0] && count(txt[0],/\d/) > integers) return
if (decimals && txt[1] && txt[1].length > decimals) return
txt[0] = txt[0].replace(/\B(?=(\d{3})+(?!\d))/g, '.')
with (event.target) {
value = mask[1] + txt.join(',') + mask[5]
selectionStart = selectionEnd = pos + (pos==1 ? mask[1].length : count(value, /\./, pos) - dot)
}
function count(str, c, e) {
e = e || str.length
for (var n=0, i=0; i<e; i+=1) if (str.charAt(i).match(c)) n+=1
return n
}
}
function mascaraData(val) {
var pass = val.value;
var expr = /[0123456789]/;
for (i = 0; i < pass.length; i++) {
// charAt -> retorna o caractere posicionado no índice especificado
var lchar = val.value.charAt(i);
var nchar = val.value.charAt(i + 1);
if (i == 0) {
// search -> retorna um valor inteiro, indicando a posição do inicio da primeira
// ocorrência de expReg dentro de instStr. Se nenhuma ocorrencia for encontrada o método retornara -1
// instStr.search(expReg);
if ((lchar.search(expr) != 0) || (lchar > 3)) {
val.value = "";
}
} else if (i == 1) {
if (lchar.search(expr) != 0) {
// substring(indice1,indice2)
// indice1, indice2 -> será usado para delimitar a string
var tst1 = val.value.substring(0, (i));
val.value = tst1;
continue;
}
if ((nchar != '/') && (nchar != '')) {
var tst1 = val.value.substring(0, (i) + 1);
if (nchar.search(expr) != 0)
var tst2 = val.value.substring(i + 2, pass.length);
else
var tst2 = val.value.substring(i + 1, pass.length);
val.value = tst1 + '/' + tst2;
}
} else if (i == 4) {
if (lchar.search(expr) != 0) {
var tst1 = val.value.substring(0, (i));
val.value = tst1;
continue;
}
if ((nchar != '/') && (nchar != '')) {
var tst1 = val.value.substring(0, (i) + 1);
if (nchar.search(expr) != 0)
var tst2 = val.value.substring(i + 2, pass.length);
else
var tst2 = val.value.substring(i + 1, pass.length);
val.value = tst1 + '/' + tst2;
}
}
if (i >= 6) {
if (lchar.search(expr) != 0) {
var tst1 = val.value.substring(0, (i));
val.value = tst1;
}
}
}
if (pass.length > 10)
val.value = val.value.substring(0, 10);
return true;
}
</script>]]>
|