none
problemas com javascript e validator RRS feed

  • Pergunta

  • Boa tarde

    Desenvolvi um formulário web, e localmente esta funcionando perfeitamente, porém após publica-lo, meus códigos javascript e os validators não estão funcionando, e não geram nenhuma msg de erro.

    Segue abaixo pedaços do código

    Desde já agradeça qualquer auxilio

    index.aspx

      <script type="text/javascript" src="/JS/Scripts.js"></script>
    
    <br/>
    
    
    
    <asp:View ID="vwCadCliente" runat="server">
          <table>
            <tr>
              <td class="style50">
                &nbsp;</td>
              <td align="left" class="styleTitulos" colspan="2">
                Dados Pessoais
              </td>
              <td align="right" class="style110">
                &nbsp;</td>
              <td class="style195">
                &nbsp;</td>
            </tr>
            <tr>
              <td class="style188" colspan="2">
                &nbsp;<span class="styleTextinhos">CNPJ / CPF</span></td>
              <td class="style191">
                <asp:TextBox ID="txtCpfCnpj" runat="server" MaxLength="18" TabIndex="2" 
                  Width="185px"></asp:TextBox>
              </td>
              <td align="right" class="styleTextinhos">
                Fone Cel
              </td>
              <td class="style195">
                <asp:TextBox ID="txtFone1" runat="server" MaxLength="14" onkeyup="formataTelefone(this,event);"
                  TabIndex="10"></asp:TextBox>
                <asp:RequiredFieldValidator ID="rfvFone1" runat="server" ControlToValidate="txtFone1"
                  Display="None" ErrorMessage="O campo Fone Cel deve ser preenchido" 
                  ValidationGroup="CadCliente"></asp:RequiredFieldValidator>
              </td>
            </tr>
            <tr>
              <td class="style187" colspan="2">
                &nbsp;<span class="style165">Nome completo</span></td>
              <td class="style191">
                <asp:TextBox ID="txtNome" runat="server" MaxLength="50" TabIndex="1" 
                  Width="183px"></asp:TextBox>
                <asp:RequiredFieldValidator ID="rfvNomeCompleto" runat="server" 
                  ControlToValidate="txtNome" Display="None" 
                  ErrorMessage="O campo Nome completo deve ser preenchido" 
                  ValidationGroup="CadCliente"></asp:RequiredFieldValidator>
              </td>
              <td align="right" class="style175">
                Fone Com
              </td>
              <td class="style195">
                <asp:TextBox ID="txtFone2" runat="server" MaxLength="14" 
                  onkeyup="formataTelefone(this,event);" TabIndex="11"></asp:TextBox>
                <asp:RequiredFieldValidator ID="rfvFone2" runat="server" 
                  ControlToValidate="txtFone2" Display="None" 
                  ErrorMessage="O campo Fone Com deve ser preenchido" 
                  ValidationGroup="CadCliente"></asp:RequiredFieldValidator>
              </td>
            </tr>
            <tr>
              <td class="style175">
                Endereço
              </td>
              <td align="right" class="style184">
                Cep
              </td>
              <td class="style191">
                <asp:TextBox ID="txtCep" runat="server" Height="22px" MaxLength="9" 
                  onkeyup="formataCEP(this,event);" TabIndex="3"></asp:TextBox>
                <asp:Button ID="btnBuscarEnd" runat="server" OnClick="btnBuscarEnd_Click" 
                  TabIndex="4" Text="Ok" />
                <asp:Label ID="lblResultado" runat="server" ForeColor="Red"></asp:Label>
                <asp:RequiredFieldValidator ID="rfvCep" runat="server" 
                  ControlToValidate="txtCep" Display="None" 
                  ErrorMessage="O campo Cep é obrigatório" ValidationGroup="CadCliente"></asp:RequiredFieldValidator>
                <asp:RegularExpressionValidator ID="revCep" runat="server" 
                  ControlToValidate="txtCep" Display="None" ErrorMessage="Cep Inválido" 
                  ValidationExpression="\d{5}\-\d{3}" ValidationGroup="CadCliente"></asp:RegularExpressionValidator>
              </td>
              <td align="right" class="style175">
                Bairro
              </td>
              <td class="style195">
                <asp:TextBox ID="txtBairro" runat="server" MaxLength="50" TabIndex="7" 
                  Width="188px"></asp:TextBox>
                <asp:RequiredFieldValidator ID="rfvBairro" runat="server" 
                  ControlToValidate="txtBairro" Display="None" 
                  ErrorMessage="O campo bairro é obrigatório" ValidationGroup="CadCliente"></asp:RequiredFieldValidator>
              </td>
            </tr>
            <tr>
              <td class="style5">
                &nbsp;
              </td>
              <td align="right" class="style184">
                Rua
              </td>
              <td class="style191">
                <asp:TextBox ID="txtEndereco" runat="server" MaxLength="50" Width="189px" 
                  TabIndex="5"></asp:TextBox>
                <asp:RequiredFieldValidator ID="rfvRua" runat="server" 
                  ControlToValidate="txtEndereco" Display="None" 
                  ErrorMessage="O campo rua, n° é obrigatório" ValidationGroup="CadCliente"></asp:RequiredFieldValidator>
              </td>
              <td align="right" class="style175">
                Cidade
              </td>
              <td class="style195">
                <asp:TextBox ID="txtCidade" runat="server" TabIndex="8" Width="186px"></asp:TextBox>
              </td>
            </tr>
            <tr>
              <td class="style5">
                &nbsp;
              </td>
              <td align="right" class="style184"></td>
              <td class="style191">
                <asp:TextBox ID="txtNumero" runat="server" MaxLength="6" Width="76px"></asp:TextBox>
              </td>
              <td align="right" class="style175">
                Uf
              </td>
              <td class="style195">
                <asp:DropDownList ID="ddlUf" runat="server" TabIndex="9">
                </asp:DropDownList>
              </td>
            </tr>
            <tr>
              <td class="style50">
                &nbsp;
              </td>
              <td align="right" class="style185">
                &nbsp;
              </td>
              <td class="style98">
                &nbsp;
              </td>
              <td align="right" class="style111">
                &nbsp;
              </td>
              <td class="style196">
                &nbsp;
              </td>
            </tr>
            <tr>
              <td class="style175">
                Login
              </td>
              <td align="right" class="style184">
                E-mail
              </td>
              <td class="style276">
                <asp:TextBox ID="txtEmail" runat="server" MaxLength="30" TabIndex="12"></asp:TextBox>
                <asp:RegularExpressionValidator ID="revEmail" runat="server" 
                  ControlToValidate="txtEmail" Display="None" 
                  ErrorMessage="Endereço de e-mail inválido" 
                  ValidationExpression="\w+([-+.']\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*" 
                  ValidationGroup="CadCliente"></asp:RegularExpressionValidator>
                <asp:RequiredFieldValidator ID="rfvEmail" runat="server" 
                  ControlToValidate="txtEmail" Display="None" 
                  ErrorMessage="O campo E-mail deve ser preenchido" ValidationGroup="CadCliente"></asp:RequiredFieldValidator>
              </td>
              <td class="style110" align="right">
                &nbsp;
              </td>
              <td class="style195">
                &nbsp;
              </td>
            </tr>
            <tr>
              <td class="style197">
                &nbsp;
              </td>
              <td align="right" class="style177">
                Senha
              </td>
              <td class="style198">
                <asp:TextBox ID="txtSenha" runat="server" MaxLength="10" TextMode="Password"></asp:TextBox>
              </td>
              <td class="style199" colspan="2">
                &nbsp;
                <asp:CheckBox ID="chkAssinarNews" runat="server" Checked="True" 
                  CssClass="styleTextinhos" TabIndex="11" 
                  Text="Concordo em receber e-mails com promoções exclusivas" />
              </td>
            </tr>
            <tr>
              <td class="style182">
              </td>
              <td class="style184" align="right">
                Confirmar
              </td>
              <td class="style276">
                <asp:TextBox ID="txtConfirmaSenha" runat="server" MaxLength="10" 
                  TextMode="Password"></asp:TextBox>
                <asp:CompareValidator ID="cvConfirmar" runat="server" 
                  ControlToCompare="txtSenha" ControlToValidate="txtConfirmaSenha" Display="None" 
                  ErrorMessage="Campo confirmar não esta de acordo com a senha" 
                  ValidationGroup="CadCliente"></asp:CompareValidator>
              </td>
              <td class="style110">
              </td>
              <td class="style195">
              </td>
            </tr>
            <tr>
              <td class="style5">
                &nbsp;
              </td>
              <td class="style186">
                &nbsp;
              </td>
              <td class="style191">
                <asp:ValidationSummary ID="vsCadCliente" runat="server" DisplayMode="List" 
                  Height="37px" ShowMessageBox="True" ShowSummary="False" 
                  ValidationGroup="CadCliente" />
              </td>
              <td class="style110">
                &nbsp;
              </td>
              <td class="style195">
                &nbsp;
                <asp:Button ID="btnCadCliente" runat="server" Height="25px" 
                  OnClick="btnCadCliente_Click" Text="Cadastrar" ValidationGroup="CadCliente" 
                  Width="76px" />
              </td>
            </tr>
          </table>
        </asp:View>
    
    
    quinta-feira, 3 de março de 2011 17:27

Todas as Respostas

  • web.config
    
    <?xml version="1.0"?>
    <!--
     For more information on how to configure your ASP.NET application, please visit
     http://go.microsoft.com/fwlink/?LinkId=169433
     -->
    <configuration>
     <configSections>
      <sectionGroup name="system.web.extensions" type="System.Web.Configuration.SystemWebExtensionsSectionGroup, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35">
       <sectionGroup name="scripting" type="System.Web.Configuration.ScriptingSectionGroup, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35">
        <section name="scriptResourceHandler" type="System.Web.Configuration.ScriptingScriptResourceHandlerSection, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" requirePermission="false" allowDefinition="MachineToApplication" />
        <sectionGroup name="webServices" type="System.Web.Configuration.ScriptingWebServicesSectionGroup, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35">
         <section name="jsonSerialization" type="System.Web.Configuration.ScriptingJsonSerializationSection, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" requirePermission="false" allowDefinition="Everywhere" />
         <section name="profileService" type="System.Web.Configuration.ScriptingProfileServiceSection, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" requirePermission="false" allowDefinition="MachineToApplication" />
         <section name="authenticationService" type="System.Web.Configuration.ScriptingAuthenticationServiceSection, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" requirePermission="false" allowDefinition="MachineToApplication" />
         <section name="roleService" type="System.Web.Configuration.ScriptingRoleServiceSection, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" requirePermission="false" allowDefinition="MachineToApplication" />
        </sectionGroup>
       </sectionGroup>
      </sectionGroup>
     </configSections>
     <system.web>
      <customErrors mode="Off"/>
      <compilation debug="false">
       <assemblies>
        <add assembly="System.Data.Entity, Version=3.5.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
        <add assembly="System.Core, Version=3.5.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089" />
        <add assembly="System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
        <add assembly="System.Xml.Linq, Version=3.5.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089" />
        <add assembly="System.Data.DataSetExtensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089" />
       </assemblies>
      </compilation>
      <pages>
       <controls>
        <add tagPrefix="asp" namespace="System.Web.UI" assembly="System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
        <add tagPrefix="asp" namespace="System.Web.UI.WebControls" assembly="System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
       </controls>
      </pages>
      <httpHandlers>
       <remove verb="*" path="*.asmx" />
       <add verb="*" path="*.asmx" validate="false" type="System.Web.Script.Services.ScriptHandlerFactory, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
       <add verb="*" path="*_AppService.axd" validate="false" type="System.Web.Script.Services.ScriptHandlerFactory, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
       <add verb="GET,HEAD" path="ScriptResource.axd" validate="false" type="System.Web.Handlers.ScriptResourceHandler, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
      </httpHandlers>
      <httpModules>
       <add name="ScriptModule" type="System.Web.Handlers.ScriptModule, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
      </httpModules>
     </system.web>
     <connectionStrings>
    
      <add name="InsideEntities" connectionString="" />
     </connectionStrings>
     <system.net>
      <mailSettings>
       <smtp></smtp>
      </mailSettings>
     </system.net>
     <system.codedom>
      <compilers>
       <compiler language="c#;cs;csharp" extension=".cs" type="Microsoft.CSharp.CSharpCodeProvider, System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" warningLevel="4">
        <providerOption name="CompilerVersion" value="v3.5" />
        <providerOption name="WarnAsError" value="false" />
       </compiler>
      </compilers>
     </system.codedom>
     <system.webServer>
      <validation validateIntegratedModeConfiguration="false" />
      <modules>
       <remove name="ScriptModule" />
       <add name="ScriptModule" preCondition="managedHandler" type="System.Web.Handlers.ScriptModule, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
      </modules>
      <handlers>
       <remove name="WebServiceHandlerFactory-Integrated" />
       <remove name="ScriptHandlerFactory" />
       <remove name="ScriptHandlerFactoryAppServices" />
       <remove name="ScriptResource" />
       <add name="ScriptHandlerFactory" verb="*" path="*.asmx" preCondition="integratedMode" type="System.Web.Script.Services.ScriptHandlerFactory, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
       <add name="ScriptHandlerFactoryAppServices" verb="*" path="*_AppService.axd" preCondition="integratedMode" type="System.Web.Script.Services.ScriptHandlerFactory, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
       <add name="ScriptResource" verb="GET,HEAD" path="ScriptResource.axd" preCondition="integratedMode" type="System.Web.Handlers.ScriptResourceHandler, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
      </handlers>
     </system.webServer>
     <runtime>
      <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1" appliesTo="v2.0.50727">
       <dependentAssembly>
        <assemblyIdentity name="System.Web.Extensions" publicKeyToken="31bf3856ad364e35" />
        <bindingRedirect oldVersion="1.0.0.0-1.1.0.0" newVersion="3.5.0.0" />
       </dependentAssembly>
       <dependentAssembly>
        <assemblyIdentity name="System.Web.Extensions.Design" publicKeyToken="31bf3856ad364e35" />
        <bindingRedirect oldVersion="1.0.0.0-1.1.0.0" newVersion="3.5.0.0" />
       </dependentAssembly>
      </assemblyBinding>
     </runtime>
    </configuration>
    
    
    
    
    
    quinta-feira, 3 de março de 2011 17:28
  • Este erro acontece com apenas alguns usuários? ou com todos?

    se o Navegador estiver com o JavaScript desabilitado, a verificação no lado do cliente não será realizada.

    Ai voce teria que utlizar a validação no servidor, pode usar:

    if Page.isValid then

    end if


    Caio Vitullo
    quinta-feira, 3 de março de 2011 17:59
  • Obrigado pela resposta

    Não esta funcionando em nenhum cliente ou navegador

    o problema pode estar no lado do servidor?

    quinta-feira, 3 de março de 2011 18:18
  • Acho que achei. ta neste atributo dentro do validador:

    Display="None"

    troca para:

    Display="Dynamic"

     

     

     


    Caio Vitullo

     

     

    ve se funciona

    quinta-feira, 3 de março de 2011 21:43
  • Caio,

    obrigado pela ajuda,

    o display = none é proposital, pois o validationSummary vai exibir um msgbox com os erros

    o problema estava logo na primeira linha

    <
    script
     type
    =
    "text/javascript"
     src
    =
    "/JS/Scripts.js"
    >
    </
    script
    >
    

    após retirar a barra do src

    src="JS/Scripts.js" o javascript a página publicada passou a funcionar.

    meio dia de trabalho por causa de uma maldita barra :(

    após corrigir isso os validator passaram a funcionar, ainda não entendi a relação, quando tiver um tempo analiso.

    sexta-feira, 4 de março de 2011 13:15