如何在 html 中创建文本框,如 Outlook To(收件人姓名)
How to create a textbox like Outlook To (names of the recipients) in html
我需要创建一个文本框控件,如 Outlook To .基本上我需要输入一些用分号分隔的用户名,Ctrl K(或按钮单击(将验证用户是否喜欢在 Outlook 中。
任何人都可以在这里帮忙。
提前谢谢。
这是一个非常快速和肮脏的例子,你可以尝试什么,显然可以进行改进,但在大多数情况下会发生这样的事情。
// list of possible matches
var names = ['john', 'ben', 'dylan', 'kelly', 'beth']
// on form submission
$('form').on('submit', function(){
// get the input
var text = $('input[type=text]').val()
var match = text;
// check each name
names.forEach(function(e,i){
// check if the name matches
if(e.indexOf(text) > -1) {
// found a match, set it
match = e
}
})
// update the input
$('input[type=text]').val(match)
})
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<form>
<input type="text">
<input type="submit" value="Validate">
</form>
相关文章:
- 节点Js:How to catch a“;没有这样的文件或目录“;读取线模块出错
- jQuery AJAX write to XML
- grep in JQuery to C#
- how to convert html <div> to pdf
- Node.js - POST to iFrame?
- SVG xml to image
- Advantages to DOMParser vs template & innerHTML
- how to split a string with ','
- How to declare a Map containing certain properties with flow
- Php variable obj to js
- 如何在submit to sightly时将表单输入值作为参数传递给WCMUsePojo
- D3JS selectAll to append rect
- Javascript connect to websocket
- Underscore each to update collection
- 在哪里可以找到R-to-JavaScript编译器
- SCEditor BBcode to HTML parsing
- Javascript RegEx to XML Schema RegEx
- How to apply javascript on <asp:Buttonfield>?
- PHP Vars to JavaScript Laravel 5.2
- 如何在 html 中创建文本框,如 Outlook To(收件人姓名)