Show warning window with text box in it

I am new to jquery. I want to show a warning window with a TextBox field in it when the page loads. Something like that:

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 reach the above notification window? Do I have to manually encode it?
A preferred example is jQuery . I am trying to do this for my chat application, where you need to specify the username in the chat. I searched alot but could not find anything useful related to asp.net and jquery.

+4
source share
5 answers

Just use the good old JavaScript:

 var text = prompt("prompt", "textbox intial text"); 

Live demo

+16
source

Casting an example in jQuery is preferable.

jQuery Impromptu provides an aesthetic JavaScript hint that is equally easily invoked as the 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 }); 
+5
source

You can use the jQueryUI Dialog to display the form in a dialog box.

0
source

"I want to show a warning window with a TextBox field in it." a warning field with a text field is generally impossible .. (from what I have learned so far) .... you can use other jquery plugins, such as a dialog

http://jqueryui.com/dialog/

do the same thing.

or classic way using an invitation

 var name=prompt("Please enter your name","Harry Potter"); 
0
source

Try the following:

 $(document).ready(function(){ var msg = window.prompt("Write your name", "Name"); alert(msg); });​ 
0
source

All Articles