Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Web Development
  3. ASP.NET
  4. Problem with custom validator in asp.net

Problem with custom validator in asp.net

Scheduled Pinned Locked Moved ASP.NET
regexcsharpjavascriptasp-nethelp
2 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • D Offline
    D Offline
    dayakar_dn
    wrote on last edited by
    #1

    Hi, I am having one text box and two button named APPLY and START, and two custom validator, both i am validating in jquery. in one custom control i have given controlTovalidate to Textbox... for another custom control i haven't given any controltoValidate...mainly for validation on click of "Start" button... As per my knowledge both should be get tiggered.. but in one secnario like when the first custom validator args.isValid is true.. that time.. second Custom validator is not getting triggered... code of the first custom control

    if (!promoCd.match(regEx))
    // if promocode is not an integer of length 9 or 10 then return invalid
    {

                    $("#" + ClientId + "\_" + "spnPromoNotEnt").hide();
                    $("#" + ClientId + "\_" + "spnPromoNotReg").show();
                    args.IsValid = false;
                    validateResult = false;
                }
    
                else {
                    {
                        args.IsValid = true;
                        validateResult = true;
                        $("#" + ClientId + "\_" + "spnPromoNotEnt").hide();
                        $("#" + ClientId + "\_" + "spnPromoNotReg").hide();
                        $("#TopMessagePanel").hide();
            }        }
    

    when else part of the first custom code execute.. then second custom control not getting triggered

    second custom validator code

    function ValidatePromoCode(source, args) {

        if (Response == null && validateResult == true) {
    
            if ($("#" + clientId + "\_txtPromo").val().length > 0) {
                args.IsValid = false;
                            }
        }
        else if (validateResult != true) {
            $("#TopMessagePanel").hide();
        }
    

    }

    thanks in advance

    J 1 Reply Last reply
    0
    • D dayakar_dn

      Hi, I am having one text box and two button named APPLY and START, and two custom validator, both i am validating in jquery. in one custom control i have given controlTovalidate to Textbox... for another custom control i haven't given any controltoValidate...mainly for validation on click of "Start" button... As per my knowledge both should be get tiggered.. but in one secnario like when the first custom validator args.isValid is true.. that time.. second Custom validator is not getting triggered... code of the first custom control

      if (!promoCd.match(regEx))
      // if promocode is not an integer of length 9 or 10 then return invalid
      {

                      $("#" + ClientId + "\_" + "spnPromoNotEnt").hide();
                      $("#" + ClientId + "\_" + "spnPromoNotReg").show();
                      args.IsValid = false;
                      validateResult = false;
                  }
      
                  else {
                      {
                          args.IsValid = true;
                          validateResult = true;
                          $("#" + ClientId + "\_" + "spnPromoNotEnt").hide();
                          $("#" + ClientId + "\_" + "spnPromoNotReg").hide();
                          $("#TopMessagePanel").hide();
              }        }
      

      when else part of the first custom code execute.. then second custom control not getting triggered

      second custom validator code

      function ValidatePromoCode(source, args) {

          if (Response == null && validateResult == true) {
      
              if ($("#" + clientId + "\_txtPromo").val().length > 0) {
                  args.IsValid = false;
                              }
          }
          else if (validateResult != true) {
              $("#TopMessagePanel").hide();
          }
      

      }

      thanks in advance

      J Offline
      J Offline
      jkirkerx
      wrote on last edited by
      #2

      dayakar_dn wrote:

      then second custom control not getting triggered

      $("#" + ClientId + "_" + "spnPromoNotReg").hide(); Well first off, it's just a textbox, there's nothing custom about it. As far as triggering goes, it doesn't get triggered, JQuery has to be able to find that textbox in order to alter the visiblity of the textbox. If it can't find it, it won't get altered to hide. Check your spelling, or alter the way you declare the name of the textbox. args.IsValid I don't see the code or declaration for if (args.IsValid) == true { so I can't comment on it. If the condition is not met, the code will never execute.

      1 Reply Last reply
      0
      Reply
      • Reply as topic
      Log in to reply
      • Oldest to Newest
      • Newest to Oldest
      • Most Votes


      • Login

      • Don't have an account? Register

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • World
      • Users
      • Groups