Ir para conteúdo

POWERED BY:

Arquivado

Este tópico foi arquivado e está fechado para novas respostas.

mestre fyoda

Setattribut no IE

Recommended Posts

<script>function addHandlers(ID){		var elemento = document.getElementById(ID);		var onkeyp = "return txtBoxFormat(this.form, this.name, '99/99/9999', event);";		var onkeyu = "return autoTab(this, 10, event);";		elemento.setAttribute("onkeypress", onkeyp);		elemento.setAttribute("onkeyup", onkeyu);}</script><input type="text" name="cpf_cnpj" id="cpf_cnpj"/><input name="cic_cnpj" type="radio" value="cpf" checked="checked" onclick="addHandlers('cpf_cnpj');"/>

nao esta funcionando no IE , pq ?

 

 

 

codigo para a maskara :

 

function txtBoxFormat(objForm, strField, sMask, evtKeyPress) {var i, nCount, sValue, fldLen, mskLen,bolMask, sCod, nTecla;if(document.all) { // Internet Explorer	nTecla = evtKeyPress.keyCode;} else if(document.layers) { // Nestcape	nTecla = evtKeyPress.which;} else {	nTecla = evtKeyPress.which;	if (nTecla == 8) {		return true;	}}sValue = objForm[strField].value;// Limpa todos os caracteres de formatação que// já estiverem no campo.sValue = sValue.toString().replace(/\-/g, "");sValue = sValue.toString().replace(/\./g, "");sValue = sValue.toString().replace(/\//g, "");sValue = sValue.toString().replace(/\(/g, "");sValue = sValue.toString().replace(/\)/g, "");sValue = sValue.toString().replace(/\s/g, "");fldLen = sValue.length;mskLen = sMask.length;i = 0;nCount = 0;sCod = "";mskLen = fldLen;while (i <= mskLen) {bolMask = ((sMask.charAt(i) == "-") || (sMask.charAt(i) == ":") || (sMask.charAt(i) == ".") || (sMask.charAt(i) == "/"))bolMask = bolMask || ((sMask.charAt(i) == "(") || (sMask.charAt(i) == ")") || (sMask.charAt(i) == " "))if (bolMask) {	sCod += sMask.charAt(i);	mskLen++;} else {	sCod += sValue.charAt(nCount);	nCount++;}i++;}objForm[strField].value = sCod;if (nTecla != 8) { // backspace	if (sMask.charAt(i-1) == "9") { // apenas números...	return ((nTecla > 47) && (nTecla < 58)); } // números de 0 a 9else { // qualquer caracter...	return true;}} else {	return true;}}//Fim da Função Máscaras Gerais/**** AUTO TAB - ao prencher o campo, automaticamente manda o foco para o próximo!***/var isNN = (navigator.appName.indexOf("Netscape")!=-1);function autoTab(input,len, e) {	var keyCode = (isNN) ? e.which : e.keyCode;	var filter = (isNN) ? [0,8,9] : [0,8,9,16,17,18,37,38,39,40,46];	if(input.value.length >= len && !containsElement(filter,keyCode)) {		input.value = input.value.slice(0, len);		input.form[(getIndex(input)+1) % input.form.length].focus();	}function containsElement(arr, ele) {	var found = false, index = 0;	while(!found && index < arr.length)	if(arr[index] == ele)		found = true;	else		index++;		return found;	}function getIndex(input) {	var index = -1, i = 0, found = false;	while (i < input.form.length && index == -1)		if (input.form[i] == input)index = i;		else i++;		return index;	}	return true;}

Compartilhar este post


Link para o post
Compartilhar em outros sites
function addHandlers(ID){		var elemento = document.getElementById(ID);		elemento.onkeypress = function(){return txtBoxFormat(this.form, this.name, '99/99/9999', event);};		elemento.onkeyup = function(){return autoTab(this, 10, event);};}

Compartilhar este post


Link para o post
Compartilhar em outros sites

×

Informação importante

Ao usar o fórum, você concorda com nossos Termos e condições.