Java Script doesn't work in my ASP.Net, wrong code?
-
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>
-
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>
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; } }
-
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; } }
-
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; } }
Nilesh Hapse wrote:
if (result) { return true; } else { return false; }
return result
? :)Small angry dogs
-
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; } }
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
-
Nilesh Hapse wrote:
if (result) { return true; } else { return false; }
return result
? :)Small angry dogs
That's most obvious thing. :) But I just replied to the question or in other words i just had a look at problem area. ;)
-
That's most obvious thing. :) But I just replied to the question or in other words i just had a look at problem area. ;)
I was aiming for the original poster, not you - sorry. I realised you just cut'n'paste the code.
Small angry dogs