Is there any way to create prompt in JavaScript with two input fields ?
I tried that code, but it didn't help me :
var a = prompt("A : ", "");
var b = prompt("B : ", "");
alert(a + "\n" + b);
This is not possible with an OS or native browser window popping up. You will have to create a custom overlay dialog.
I would advise using a library like jQuery UI to do this. You can then customize whatever is in the popup.
You can view a demo of the dialog here
JavaScript Code
<script>
$( "#create-user" )
.button()
.click(function() {
$( "#dialog-form" ).dialog( "open" );
});
});
</script>
Html Code:
<div id="dialog-form" title="Create new user">
<p class="validateTips">All form fields are required.</p>
<form>
<fieldset>
<label for="name">Name</label>
<input type="text" name="name" id="name" class="text">
<label for="email">Email</label>
<input type="text" name="email" id="email" value="" class="text">
<label for="password">Password</label>
<input type="password" name="password" id="password" value="" class="text">
</fieldset>
</form>
</div>
<button id="create-user">Create new user</button>
function abrete() {
$("#dialog").dialog();
}
<link rel="stylesheet" href="https://code.jquery.com/ui/1.12.1/themes/base/jquery-ui.css">
<script src="https://code.jquery.com/jquery-1.12.4.js"></script>
<script src="https://code.jquery.com/ui/1.12.1/jquery-ui.js"></script>
<div id="dialog" title="Create new user" style="display:none;">
<p class="validateTips">All form fields are required.</p>
<form action='tuscript.php'>
<fieldset>
<label for="name">Name</label>
<input type="text" name="name" id="name" class="text">
<label for="email">Email</label>
<input type="text" name="email" id="email" value="" class="text">
<label for="password">Password</label>
<input type="password" name="password" id="password" value="" class="text">
</fieldset>
</form>
</div>
<button onclick='abrete()'>Create new user</button>