﻿function mascaraCEP(campo,xEvent) 
{
    var strCheck = '0123456789';
    var key = '';
    var whichCode = (window.Event) ? xEvent.which : xEvent.keyCode;
    if (whichCode == undefined) whichCode = xEvent.keyCode;
    if (whichCode == 13 || whichCode == 8 || whichCode == 0) return true;
    key = String.fromCharCode(whichCode); // Valor para o código da Chave
    if (strCheck.indexOf(key) == -1) return false; // Chave inválida 
	
	vr = campo.value;
	if (vr.length == 9) return false;
	if (vr.length == 5) campo.value = vr + "-"
}
