I can not find the error.
I have a Textbox
:
<asp:TextBox ID="un_textbox" runat="server"></asp:TextBox>
then a button:
<asp:Button ID="Button1" runat="server"
Text="Pulsa"
OnClientClick="return comprueba();" />
And this I have in a script:
<script type="text/javascript">
function comprueba() {
var txt = document.getElementById("un_textbox").value;
if (txt == "hola") {
return confirm("Confirme el postback");
}
else {
return false;
}
}
Is the error in the way of capturing in txt like this: document.getElementById("un_textbox").value;
?
In the script
it always goes by the else
, never takes the if
, as if it did not have to compare the "hello"