button click event after onblur event
-
Hallo, I have a textbox with onblur event handled with javascript. I have asp.net button. When i chage the text in textbox and directly click the button, i get a confirm box from the onblur event. How can i make the button event to fire after answering the confirm box. In other cases like press tab or clicking some other control is not a problem. example code: Textbox txt = new TextBox txt.id = "txt"; txt.attributes.add("onblur","showmsg(this.id)") Javascript: function showmsg(id) { var x = document.getElementById(id).value; if (x != "") { var res = confirm("msg"); if (res == true) { document.getElementById(id).value = x; } else { document.getElementById(id).value = ""; } } }
-
Hallo, I have a textbox with onblur event handled with javascript. I have asp.net button. When i chage the text in textbox and directly click the button, i get a confirm box from the onblur event. How can i make the button event to fire after answering the confirm box. In other cases like press tab or clicking some other control is not a problem. example code: Textbox txt = new TextBox txt.id = "txt"; txt.attributes.add("onblur","showmsg(this.id)") Javascript: function showmsg(id) { var x = document.getElementById(id).value; if (x != "") { var res = confirm("msg"); if (res == true) { document.getElementById(id).value = x; } else { document.getElementById(id).value = ""; } } }
document.getelementbyid('yourButtonId').click();
I didn't get any requirements for the signature
-
document.getelementbyid('yourButtonId').click();
I didn't get any requirements for the signature
-
Thanks, But how to detect that it is button click event after onblur event. I mean i want to fire the button click event only if the button is pressed immediately after changing text in textbox.
How come you can not do this the easy way and set the autopostaback of the textbox to true and use the code behind for that event? I don't have a good answer for you to know if an event occurs immediately after another event. You may have to use a global variable and a javascript timer. I have no idea.
I didn't get any requirements for the signature
-
How come you can not do this the easy way and set the autopostaback of the textbox to true and use the code behind for that event? I don't have a good answer for you to know if an event occurs immediately after another event. You may have to use a global variable and a javascript timer. I have no idea.
I didn't get any requirements for the signature
-
I do not want autopostback on textbox. There should be some way to detect button click event in javascript.
gbabu17 wrote:
There should be some way to detect button click event in javascript.
There is. Most HTML tags have onclick event. Reference this http://www.w3schools.com/jsref/jsref_onClick.asp[^]
I didn't get any requirements for the signature