﻿var aspnet_prefix = "ctl00_masterContent_"; var email_anterior = ""; $(function () { isAuthenticated(function (a) { if (a) { $("#regrasdoforum").hide() } }); email_anterior = $("#" + aspnet_prefix + "txtEmail").val() }); function Validar(c) { var a = $.trim($("#" + aspnet_prefix + "txtLoginCadastro").val()); var b = $.trim($("#" + aspnet_prefix + "txtEmail").val()); if ($.trim($("#" + aspnet_prefix + "txtNome").val()) == "") { alert("Informe o Nome."); $("#" + aspnet_prefix + "txtNome").focus(); return false } if (b == "") { alert("Informe o Email."); $("#" + aspnet_prefix + "txtEmail").focus(); return false } if (!/^([\w-\.]+)@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.)|(([\w-]+\.)+))([a-zA-Z]{2,4}|[0-9]{1,3})(\]?)$/.test(b)) { alert("Email inválido."); $("#" + aspnet_prefix + "txtEmail").focus(); return false } if (!c) { if (a == "") { alert("Informe o Login."); $("#" + aspnet_prefix + "txtLoginCadastro").focus(); return false } if (!/^[a-zA-Z0-9._]{1,40}$/.test(a)) { alert("Login inválido."); $("#" + aspnet_prefix + "txtLoginCadastro").focus(); return false } } if (!c && $.trim($("#" + aspnet_prefix + "txtSenhaCadastro").val()) == "") { alert("Informe a Senha."); $("#" + aspnet_prefix + "txtSenhaCadastro").focus(); return false } if ($.trim($("#" + aspnet_prefix + "ddlSexo").val()) == "0") { alert("Informe o Sexo."); $("#" + aspnet_prefix + "ddlSexo").focus(); return false } if ($("#" + aspnet_prefix + "ddlEstado").val() == "0") { alert("Informe o Estado."); $("#" + aspnet_prefix + "ddlEstado").focus(); return false } if (!c && $("#chkRegras").attr("checked") == false) { alert("Você deve aceitar as Regras do Forum para se cadastrar no Site."); $("#chkRegras").focus(); return false } ValidarLoginEmail(c, a, b) } function ValidarLoginEmail(c, a, b) { if ((c && b != email_anterior) || !c) { var d = "{login: '" + a + "', email: '" + b + "'}"; ajaxProxy("WsUsuario", "ValidarLoginEmail", d, function (e) { if (e.Error) { alert(e.Error) } else { var f = ""; if (c && (b != email_anterior) && e.Email) { f = "Email" } else { if (!c && e.Email) { f = "Email" } else { if (!c && e.Login) { f = "Login" } else { __doPostBack("ctl00$masterContent$btnCadastrar", "teste") } } } if (f != "") { alert("Este " + f + " já está sendo usado em outro cadastro.\n\nInforme um " + f + " diferente."); $("#" + aspnet_prefix + "txt" + (f == "Login" ? "LoginCadastro" : f)).focus() } } }) } else { __doPostBack("ctl00$masterContent$btnCadastrar", "teste") } };
