Reputation: 41832
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.
Upvotes: 7
Views: 42239
Reputation: 552
Just use good old JavaScript:
var text = prompt("prompt", "textbox's intial text");
Upvotes: 23
Reputation: 8068
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 });
Upvotes: 5
Reputation: 13248
Try this:
$(document).ready(function(){
var msg = window.prompt("Write your name", "Name");
alert(msg);
});
Upvotes: 0
Reputation: 36531
"I want to show a Alert Box with TextBox field in it,". alert box with text field is not possible at all..(from what i have learnt till now).... u can use other jquery plugins like dialog
to do the same..
or the classic way using prompt
var name=prompt("Please enter your name","Harry Potter");
Upvotes: 0