我的表单上有一个名为itens的字段,我有一个按钮可以添加更多字段到itens但我想要的是Ctrl + V并粘贴一个列表来自word或什么编程,字段将自动创建粘贴的内容。
有什么想法吗?
<html><head
<meta charset="utf-8">
<title>Test</title>
<meta http-equiv="Content-type" content="text/html;charset=UTF-8">
<meta http-equiv="Content-Language" content="en">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="icon" type="image/x-icon" href="/asset/img/favicon.ico">
<!--[if lt IE 9]>
<script src="https://cdn.jsdelivr.net/html5shiv/3.7.2/html5shiv.min.js"></script>
<script src="https://cdn.jsdelivr.net/respond/1.4.2/respond.min.js"></script>
<![endif]-->
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-BVYiiSIFeK1dGmJRAkycuHAHRg32OmUcww7on3RYdg4Va+PmSTsz/K68vbdEjh4u" crossorigin="anonymous">
<link href="https://maxcdn.bootstrapcdn.com/font-awesome/4.6.3/css/font-awesome.min.css" rel="stylesheet" integrity="sha384-T8Gy5hrqNKT+hzMclPo118YTQO6cYprQmhrYwIiQ/3axmI1hQomh7Ud2hPOy8SP1" crossorigin="anonymous">
<link href="/bundles/c588c3c0468f4633c99de6e16289c863.css" rel="stylesheet">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.4/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js" integrity="sha384-Tc5IQib027qvyjSMfHjOMaLkfuWVxZxUPnCJA7l2mCWNIpG9mGCD8wGNIcPD7Txa" crossorigin="anonymous"></script>
<div></div></head>
<body class="demo-bootstrap">
<div class="container">
<div class="row">
<div class="col-xs-12" id="demoContainer" style="height: auto">
<form id="surveyForm" method="post" class="form-horizontal fv-form fv-form-bootstrap" novalidate="novalidate"><button type="submit" class="fv-hidden-submit" style="display: none; width: 0px; height: 0px;"></button>
<div class="form-group has-feedback">
<label class="col-xs-3 control-label">Question</label>
<div class="col-xs-5">
<input class="form-control" name="question" data-fv-field="question" type="text"><i style="display: none;" class="form-control-feedback" data-fv-icon-for="question"></i>
<small style="display: none;" class="help-block" data-fv-validator="notEmpty" data-fv-for="question" data-fv-result="NOT_VALIDATED">The question required and cannot be empty</small></div>
</div>
<div class="form-group has-feedback">
<label class="col-xs-3 control-label">Options</label>
<div class="col-xs-5">
<input class="form-control" name="option[]" data-fv-field="option[]" type="text"><i style="display: none;" class="form-control-feedback" data-fv-icon-for="option[]"></i>
<small style="display: none;" class="help-block" data-fv-validator="notEmpty" data-fv-for="option[]" data-fv-result="NOT_VALIDATED">The option required and cannot be empty</small><small style="display: none;" class="help-block" data-fv-validator="stringLength" data-fv-for="option[]" data-fv-result="NOT_VALIDATED">The option must be less than 100 characters long</small></div>
<div class="col-xs-4">
<button type="button" class="btn btn-default addButton"><i class="fa fa-plus"></i></button>
</div>
</div>
<!-- The option field template containing an option field and a Remove button -->
<div class="form-group hide has-feedback" id="optionTemplate">
<div class="col-xs-offset-3 col-xs-5">
<input class="form-control" name="option[]" data-fv-field="option[]" type="text"><i style="display: none;" class="form-control-feedback" data-fv-icon-for="option[]"></i>
<small style="display: none;" class="help-block" data-fv-validator="notEmpty" data-fv-for="option[]" data-fv-result="NOT_VALIDATED">The option required and cannot be empty</small><small style="display: none;" class="help-block" data-fv-validator="stringLength" data-fv-for="option[]" data-fv-result="NOT_VALIDATED">The option must be less than 100 characters long</small></div>
<div class="col-xs-4">
<button type="button" class="btn btn-default removeButton"><i class="fa fa-minus"></i></button>
</div>
</div>
<div class="form-group">
<div class="col-xs-5 col-xs-offset-3">
<button type="submit" class="btn btn-default">Validate</button>
</div>
</div>
</form>
<script>
$(document).ready(function() {
// The maximum number of options
var MAX_OPTIONS = 5;
$('#surveyForm')
.formValidation({
framework: 'bootstrap',
icon: {
valid: 'glyphicon glyphicon-ok',
invalid: 'glyphicon glyphicon-remove',
validating: 'glyphicon glyphicon-refresh'
},
fields: {
question: {
validators: {
notEmpty: {
message: 'The question required and cannot be empty'
}
}
},
'option[]': {
validators: {
notEmpty: {
message: 'The option required and cannot be empty'
},
stringLength: {
max: 100,
message: 'The option must be less than 100 characters long'
}
}
}
}
})
// Add button click handler
.on('click', '.addButton', function() {
var $template = $('#optionTemplate'),
$clone = $template
.clone()
.removeClass('hide')
.removeAttr('id')
.insertBefore($template),
$option = $clone.find('[name="option[]"]');
// Add new field
$('#surveyForm').formValidation('addField', $option);
})
// Remove button click handler
.on('click', '.removeButton', function() {
var $row = $(this).parents('.form-group'),
$option = $row.find('[name="option[]"]');
// Remove element containing the option
$row.remove();
// Remove field
$('#surveyForm').formValidation('removeField', $option);
})
// Called after adding new field
.on('added.field.fv', function(e, data) {
// data.field --> The field name
// data.element --> The new field element
// data.options --> The new field options
if (data.field === 'option[]') {
if ($('#surveyForm').find(':visible[name="option[]"]').length >= MAX_OPTIONS) {
$('#surveyForm').find('.addButton').attr('disabled', 'disabled');
}
}
})
// Called after removing the field
.on('removed.field.fv', function(e, data) {
if (data.field === 'option[]') {
if ($('#surveyForm').find(':visible[name="option[]"]').length < MAX_OPTIONS) {
$('#surveyForm').find('.addButton').removeAttr('disabled');
}
}
});
});
</script>
<script>
$(document).ready(function() {
$('#surveyForm')
.on('added.field.fv removed.field.fv', function(e, data) {
var $body = $('body'),
$iframe = $body.data('iframe.fv');
if ($iframe) {
// Adjust the height of iframe
$iframe.height($body.height());
}
});
});
</script>
</div>
</div>
</div>
</body></html>
我想要的是从单词中复制此列表,例如: enter image description here
并且itens将自动在其字段上