I am new to jquery. I want to show a Alert Box with TextBox field in it, whenever the page loads. Something like this:
Enter Your Username: //Title
___________________ //TextBox field (value will be stored in var for later use)
OK //Button
I know
var username = "username"; //already entered message
alert(username);
How to achieve the above Alert Box? should I manually code it?
Giving an example in jQuery
is preferable. I am trying to do this for my chat application where username is required to show in the chat. I searched alot but couldn't find any useful related to asp.net and jquery.
Just use good old JavaScript:
var text = prompt("prompt", "textbox's intial text");
Live Demo
Giving an example in jQuery is preferable.
jQuery Impromptu provides an aesthetic JavaScript Prompt, which is equally easy to call as JavaScripts window.prompt
method:
//Simple Prompt
$.prompt('Example 1');
//Opacity of the modal
$.prompt('Example 3',{ opacity: 0.2 });
//Adding Callbacks
function mycallbackfunc(e,v,m,f){
alert('i clicked ' + v);
}
$.prompt('Example 8',{ callback: mycallbackfunc });
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With