Is there any way to create prompt with two input fields?

蹲街弑〆低调 提交于 2019-11-29 05:26:41

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

Short of constructing your own using DOM methods and Input elements: No.

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>
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>dialogo</title>
<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>
</head>
<body>
<script>
function abrete(){
$("#dialog" ).dialog();
}
</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>
</body>
</html>
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!