﻿function ValidaCartao(theForm)
{
	// Valida o Cartao
	if ( (theForm.Cartao.value == "") |
		(theForm.Cartao.value.length < 13) |
		(theForm.Cartao.value.length > 13) )
	{
		alert("Por favor, digite o número do cartão com 13 dígitos");
		theForm.Cartao.focus();
		return (false);
	}

   document.getElementById("Cartao").value = document.getElementById("Cartao").value.substring(0,10) + '00' + document.getElementById("Cartao").value.substring(10,13);

	var checkOK = "0123456789-";
	var checkStr = theForm.Cartao.value;
	var allValid = true;
	var decPoints = 0;
	var allNum = "";

	for (i = 0;  i < checkStr.length;  i++)
	{
		ch = checkStr.charAt(i);
	    
		for (j = 0;  j < checkOK.length;  j++)
		if (ch == checkOK.charAt(j))
		break;
		if (j == checkOK.length)
		{
			allValid = false;
			break;
		}
		allNum += ch;
	}

	if (!allValid)

	{
		alert("Por favor, digite apenas números no cartão do usuário.");
		theForm.Cartao.focus();
		theForm.Cartao.value = "";
		return (false);
	}
	   
	// Valida a senha

	if ( (theForm.Senha.value == "") )
	{
		alert("Por favor, digite a senha do usuário.");
		theForm.Senha.focus();
		return (false);
	}

}


