简体   繁体   中英

How do i display the modal box after the input in the input column is filled?

输入栏中的输入用条码扫描器填充后,如何显示模态框,并由之前的输入框中的条码扫描器以模态填充输入。

 $( function() { $("#barcode").click(function(){ var value=$(this).attr("value"); $( "#result" ).val(value); }); $( "#result" ).focusout(function() { if( !$(this).val()) { alert("input is empty"); } else{ $( "#dialog" ).dialog(); } }); });
 #dialog{ display:none; }
 <!doctype html> <html lang="en"> <head> <meta charset="utf-8"> <meta name="viewport" content="width=device-width, initial-scale=1"> <title>Test</title> <link rel="stylesheet" href="//code.jquery.com/ui/1.12.1/themes/base/jquery-ui.css"> <link rel="stylesheet" href="/resources/demos/style.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> <button id="barcode" value="ProductXXX">Barcode Scanner</button><br> <div id="dialog" title="Modal"> <p>Congratulation! The input is not empty.</p> </div> <form id="basic"> <input type="text" name="result" id="result" placeholder="Type something in"> </form> </body> </html>

do you mean something like this? if you type in something and focus out it checks whether input was empty or not and gives you a message

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM