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. requiredfieldvalidator

requiredfieldvalidator

Scheduled Pinned Locked Moved ASP.NET
tutorial
7 Posts 4 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
    dotnetmember
    wrote on last edited by
    #1

    Hi, I have four textboxes in my web page. I want to apply required field validator such that atleast one of the text box value is required,it is mandatory to have value in any one of the four . how to validate that.

    N M B 3 Replies Last reply
    0
    • D dotnetmember

      Hi, I have four textboxes in my web page. I want to apply required field validator such that atleast one of the text box value is required,it is mandatory to have value in any one of the four . how to validate that.

      N Offline
      N Offline
      nishant jha
      wrote on last edited by
      #2

      You can use requiredfiledvalidator property of textboxex.

      Your name:
      Use the Textbox name as per ur project.

      D 1 Reply Last reply
      0
      • N nishant jha

        You can use requiredfiledvalidator property of textboxex.

        Your name:
        Use the Textbox name as per ur project.

        D Offline
        D Offline
        dotnetmember
        wrote on last edited by
        #3

        My requirement is that i need only one textbox out of four to be validated, it can be any textbox. If i use required field validator for all textbox, it validates all four textboxes which is not my need. It is sufficient to have value in any of these four

        N 1 Reply Last reply
        0
        • D dotnetmember

          Hi, I have four textboxes in my web page. I want to apply required field validator such that atleast one of the text box value is required,it is mandatory to have value in any one of the four . how to validate that.

          M Offline
          M Offline
          m dhu
          wrote on last edited by
          #4

          I think it is not possible for requiredfield validator to validate multiple controls. Try with custom validator.

          N 1 Reply Last reply
          0
          • D dotnetmember

            My requirement is that i need only one textbox out of four to be validated, it can be any textbox. If i use required field validator for all textbox, it validates all four textboxes which is not my need. It is sufficient to have value in any of these four

            N Offline
            N Offline
            nishant jha
            wrote on last edited by
            #5

            Take Foyr textbox on the page... make one function "txtnull" and copy the code... ------------------------------------------------------------------ protected void Button1_Click(object sender, EventArgs e) { txtnull(); if (n == 4) { Response.Write("alert('Atleast one')"); return; } } int n = 0; private void txtnull() { if (TextBox1.Text == "") { n++; } if (TextBox2.Text == "") { n++; } if (TextBox3.Text == "") { n++; } if (TextBox4.Text == "") { n++; } } ------------------------------------------------------------------

            1 Reply Last reply
            0
            • M m dhu

              I think it is not possible for requiredfield validator to validate multiple controls. Try with custom validator.

              N Offline
              N Offline
              nishant jha
              wrote on last edited by
              #6

              Done..

              1 Reply Last reply
              0
              • D dotnetmember

                Hi, I have four textboxes in my web page. I want to apply required field validator such that atleast one of the text box value is required,it is mandatory to have value in any one of the four . how to validate that.

                B Offline
                B Offline
                Brij
                wrote on last edited by
                #7

                As sugested, use customvalidator and in the js function write your code to check your requirement.It can't be done through requiredfieldvalidator

                Cheers!! Brij

                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