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. Asp.net 2.0 + c#

Asp.net 2.0 + c#

Scheduled Pinned Locked Moved ASP.NET
csharpasp-net
17 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.
  • S Sylvester george

    No buddy. It works in client side. Anyway the javascript code for mandatory text field is here function RequiredField() { document.getElementById("lblErrormessage").innerText = ''; if(document.getElementById("TextBox1").value == '') { document.getElementById("lblErrormessage").innerText = "Field is required"; return false; } return true; } add this method in Page_Load event code bahind on some submit button onclick like button1.Attributes.Add("onclick","return RequiredField()");

    Regards, Sylvester G Senior Software Engineer Xoriant Solutions sylvester_g_m@yahoo.com

    R Offline
    R Offline
    ritu4321
    wrote on last edited by
    #7

    no i have a problem here . i have two textboxes .The problem is with this . At a time only one label gives text the other is not. i cant understand this . function checknews() { var reqheadline,reqnewsdetail; reqheadline=document.getElementById("TextBox1").innerText; reqnewsdetail=document.getElementById("TextBox2").innerText ; alert(reqnewsdetail); if(reqheadline=="") { document.getElementById("label5").innerText = "Enter Headline" ; return false; } if(reqnewsdetail=="") { alert("bhavna"); document.getElementById("label6").innerText = "Enter News Details" ; return false ; } return true; }

    S 1 Reply Last reply
    0
    • R ritu4321

      no i have a problem here . i have two textboxes .The problem is with this . At a time only one label gives text the other is not. i cant understand this . function checknews() { var reqheadline,reqnewsdetail; reqheadline=document.getElementById("TextBox1").innerText; reqnewsdetail=document.getElementById("TextBox2").innerText ; alert(reqnewsdetail); if(reqheadline=="") { document.getElementById("label5").innerText = "Enter Headline" ; return false; } if(reqnewsdetail=="") { alert("bhavna"); document.getElementById("label6").innerText = "Enter News Details" ; return false ; } return true; }

      S Offline
      S Offline
      Sylvester george
      wrote on last edited by
      #8

      change like this. if it works give score for me if(reqheadline=="") document.getElementById("label5").innerText = "Enter Headline" ; if(reqnewsdetail=="") document.getElementById("label6").innerText = "Enter News Details" ; if(reqheadline=="" || reqnewsdetail=="") return false ;

      Regards, Sylvester G Senior Software Engineer Xoriant Solutions sylvester_g_m@yahoo.com

      R 1 Reply Last reply
      0
      • S Sylvester george

        change like this. if it works give score for me if(reqheadline=="") document.getElementById("label5").innerText = "Enter Headline" ; if(reqnewsdetail=="") document.getElementById("label6").innerText = "Enter News Details" ; if(reqheadline=="" || reqnewsdetail=="") return false ;

        Regards, Sylvester G Senior Software Engineer Xoriant Solutions sylvester_g_m@yahoo.com

        R Offline
        R Offline
        ritu4321
        wrote on last edited by
        #9

        no its not working . return true does not work now.

        S 1 Reply Last reply
        0
        • R ritu4321

          no its not working . return true does not work now.

          S Offline
          S Offline
          Sylvester george
          wrote on last edited by
          #10

          add return true; in the end. Why are you not thinking simple logiv I dont know Anyway all the best

          Regards, Sylvester G Senior Software Engineer Xoriant Solutions sylvester_g_m@yahoo.com

          R 1 Reply Last reply
          0
          • S Sylvester george

            add return true; in the end. Why are you not thinking simple logiv I dont know Anyway all the best

            Regards, Sylvester G Senior Software Engineer Xoriant Solutions sylvester_g_m@yahoo.com

            R Offline
            R Offline
            ritu4321
            wrote on last edited by
            #11

            not working var reqheadline,reqnewsdetail; reqheadline=document.getElementById("TextBox1").innerText; reqnewsdetail=document.getElementById("TextBox2").innerText ; if(reqheadline=="") document.getElementById("label5").innerText = "Enter Headline" ; if(reqnewsdetail=="") document.getElementById("label6").innerText = "Enter News Details" ; if(reqheadline=="" || reqnewsdetail=="") return false ; return true; }

            S 1 Reply Last reply
            0
            • R ritu4321

              not working var reqheadline,reqnewsdetail; reqheadline=document.getElementById("TextBox1").innerText; reqnewsdetail=document.getElementById("TextBox2").innerText ; if(reqheadline=="") document.getElementById("label5").innerText = "Enter Headline" ; if(reqnewsdetail=="") document.getElementById("label6").innerText = "Enter News Details" ; if(reqheadline=="" || reqnewsdetail=="") return false ; return true; }

              S Offline
              S Offline
              Sylvester george
              wrote on last edited by
              #12

              what is the error you are getting?

              Regards, Sylvester G Senior Software Engineer Xoriant Solutions sylvester_g_m@yahoo.com

              R 1 Reply Last reply
              0
              • S Sylvester george

                what is the error you are getting?

                Regards, Sylvester G Senior Software Engineer Xoriant Solutions sylvester_g_m@yahoo.com

                R Offline
                R Offline
                ritu4321
                wrote on last edited by
                #13

                when i fill up now the textboxes it is not getting submitted.

                S 1 Reply Last reply
                0
                • R ritu4321

                  when i fill up now the textboxes it is not getting submitted.

                  S Offline
                  S Offline
                  Sylvester george
                  wrote on last edited by
                  #14

                  why are you changing your code yourself. see my code for text box as if(document.getElementById("TextBox1").value == '') but you changed as innerText. for textbox its value for label its innerText ok

                  Regards, Sylvester G Senior Software Engineer Xoriant Solutions sylvester_g_m@yahoo.com

                  R 1 Reply Last reply
                  0
                  • S Sylvester george

                    why are you changing your code yourself. see my code for text box as if(document.getElementById("TextBox1").value == '') but you changed as innerText. for textbox its value for label its innerText ok

                    Regards, Sylvester G Senior Software Engineer Xoriant Solutions sylvester_g_m@yahoo.com

                    R Offline
                    R Offline
                    ritu4321
                    wrote on last edited by
                    #15

                    sorry for giving you the trouble. now its working . thanks

                    S 1 Reply Last reply
                    0
                    • R ritu4321

                      sorry for giving you the trouble. now its working . thanks

                      S Offline
                      S Offline
                      Sylvester george
                      wrote on last edited by
                      #16

                      You have to sharpen your Javascript knowledge. Read this link which is from w3cschools.this will help you alot http://www.w3schools.com/js/default.asp[^]

                      Regards, Sylvester G Senior Software Engineer Xoriant Solutions sylvester_g_m@yahoo.com

                      1 Reply Last reply
                      0
                      • R ritu4321

                        In my application i have two textboxes and a save button. ON clicking Save button on client side i want to check that the textboxes are not empty and display the appropriate message on the label controls. thanks in advance.

                        S Offline
                        S Offline
                        shirish78
                        wrote on last edited by
                        #17

                        You can either use javascript or requiredfield validatior for this

                        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