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. Java Script doesn't work in my ASP.Net, wrong code?

Java Script doesn't work in my ASP.Net, wrong code?

Scheduled Pinned Locked Moved Web Development
csharpjavaasp-nettoolsquestion
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.
  • H Offline
    H Offline
    hifiger2004
    wrote on last edited by
    #1

    Hi Guys, I am using some java script in my asp.net that will check the value of the textbox'txtDescription' if it is empty or not. Meaning if it is empty it will return false and if it is not empty then it will execute the confirm message. But I don't know if what should I add in order to work. The confirm('Changes have not been saved. Discard Changes?') is working but when I added the statement - if (document.getElementByID("txtDescription").value == ''){ return false; } this doesn't work anymore. What I only wanted is to check the value of txtDescription. If it is not empty then the confirm message will show up when I click the cancel button. Did I missed something in my code? hifiger2004</x-turndown>

    N 1 Reply Last reply
    0
    • H hifiger2004

      Hi Guys, I am using some java script in my asp.net that will check the value of the textbox'txtDescription' if it is empty or not. Meaning if it is empty it will return false and if it is not empty then it will execute the confirm message. But I don't know if what should I add in order to work. The confirm('Changes have not been saved. Discard Changes?') is working but when I added the statement - if (document.getElementByID("txtDescription").value == ''){ return false; } this doesn't work anymore. What I only wanted is to check the value of txtDescription. If it is not empty then the confirm message will show up when I click the cancel button. Did I missed something in my code? hifiger2004</x-turndown>

      N Offline
      N Offline
      Nilesh Hapse
      wrote on last edited by
      #2

      I think you are missing the closing } for first IF condition. The javascript should look like: function confirmation() { if (document.getElementById("txtDescription").value == '') { return false; <big>}</big> var result = confirm('Changes have not been saved. Discard changes?'); if (result) { return true; } else { return false; } }

      R M H 3 Replies Last reply
      0
      • N Nilesh Hapse

        I think you are missing the closing } for first IF condition. The javascript should look like: function confirmation() { if (document.getElementById("txtDescription").value == '') { return false; <big>}</big> var result = confirm('Changes have not been saved. Discard changes?'); if (result) { return true; } else { return false; } }

        R Offline
        R Offline
        ram1974
        wrote on last edited by
        #3

        even this should do function confirmation() { if (document.getElementById("txtDescription").value == '') { return false; } return ( confirm('Changes have not been saved. Discard changes?') ); } -Ram

        1 Reply Last reply
        0
        • N Nilesh Hapse

          I think you are missing the closing } for first IF condition. The javascript should look like: function confirmation() { if (document.getElementById("txtDescription").value == '') { return false; <big>}</big> var result = confirm('Changes have not been saved. Discard changes?'); if (result) { return true; } else { return false; } }

          M Offline
          M Offline
          Malcolm Smart
          wrote on last edited by
          #4

          Nilesh Hapse wrote:

          if (result) { return true; } else { return false; }

          return result? :)

          Small angry dogs

          N 1 Reply Last reply
          0
          • N Nilesh Hapse

            I think you are missing the closing } for first IF condition. The javascript should look like: function confirmation() { if (document.getElementById("txtDescription").value == '') { return false; <big>}</big> var result = confirm('Changes have not been saved. Discard changes?'); if (result) { return true; } else { return false; } }

            H Offline
            H Offline
            hifiger2004
            wrote on last edited by
            #5

            Thanks man, it's working fine now. Can I ask additional question here? How can I check the value of Session and Application using java?

            hifiger2004

            1 Reply Last reply
            0
            • M Malcolm Smart

              Nilesh Hapse wrote:

              if (result) { return true; } else { return false; }

              return result? :)

              Small angry dogs

              N Offline
              N Offline
              Nilesh Hapse
              wrote on last edited by
              #6

              That's most obvious thing. :) But I just replied to the question or in other words i just had a look at problem area. ;)

              M 1 Reply Last reply
              0
              • N Nilesh Hapse

                That's most obvious thing. :) But I just replied to the question or in other words i just had a look at problem area. ;)

                M Offline
                M Offline
                Malcolm Smart
                wrote on last edited by
                #7

                I was aiming for the original poster, not you - sorry. I realised you just cut'n'paste the code.

                Small angry dogs

                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