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. validators and javascript(confirm)

validators and javascript(confirm)

Scheduled Pinned Locked Moved ASP.NET
javascripthelp
4 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.
  • A Offline
    A Offline
    ali bagheri
    wrote on last edited by
    #1

    hi i have a button in my page and add this attribute to button <javascript:return confirm('Message');")>> and also i have a textbox in my page that a requirefiledvalidator check that not be empty. if i click button confirm occur for me and if i press <> the code of this event execute while textbox is empty and validator not check the textbox. when event onclick of button finished validator check the textbox. please help me thanks a lot.

    M 1 Reply Last reply
    0
    • A ali bagheri

      hi i have a button in my page and add this attribute to button <javascript:return confirm('Message');")>> and also i have a textbox in my page that a requirefiledvalidator check that not be empty. if i click button confirm occur for me and if i press <> the code of this event execute while textbox is empty and validator not check the textbox. when event onclick of button finished validator check the textbox. please help me thanks a lot.

      M Offline
      M Offline
      minhpc_bk
      wrote on last edited by
      #2

      Hi there, You didn't say what you want to do in this case? If you want not to execute the event handler in the code behind when you click OK, then you simply remove the return keyword in your sample script. If you want the validator not to validate when the OK is clicked, then in the event handler of the button you simply set the IsValid of the validator to true.

      A 1 Reply Last reply
      0
      • M minhpc_bk

        Hi there, You didn't say what you want to do in this case? If you want not to execute the event handler in the code behind when you click OK, then you simply remove the return keyword in your sample script. If you want the validator not to validate when the OK is clicked, then in the event handler of the button you simply set the IsValid of the validator to true.

        A Offline
        A Offline
        ali bagheri
        wrote on last edited by
        #3

        hi minhpc_bk, thank a lot, i want have a confirm in bottun click, when i click <> in confirm window the validator validate the textbox and if textbox not empty, execute the event handler in the code behind. but now if textbox is empty after click <> the event handler in the code behind execute. thanks bye

        M 1 Reply Last reply
        0
        • A ali bagheri

          hi minhpc_bk, thank a lot, i want have a confirm in bottun click, when i click <> in confirm window the validator validate the textbox and if textbox not empty, execute the event handler in the code behind. but now if textbox is empty after click <> the event handler in the code behind execute. thanks bye

          M Offline
          M Offline
          minhpc_bk
          wrote on last edited by
          #4

          The sample code looks something like:

          Button1.Attributes.Add("onclick", "if(!confirm('Message')) return false;");

          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