简体   繁体   English

一个带有两个不同值的选项的文本框

[英]one text box with tow option different in value

I have a form contain a textbox with tow option, one of the options is to write a just letter and the other option is to write a number, how can separate them?我有一个表单包含一个带有拖曳选项的文本框,其中一个选项是写一个简单的字母,另一个选项是写一个数字,如何将它们分开?

when the user selected journal name it should write just a letter and when select ISSN it will enter a just number? when the user selected journal name it should write just a letter and when select ISSN it will enter a just number? function ValidateTextBox(txt) {函数验证文本框(txt){

if (txt == "ISSN") {
    document.getElementById("searchword").pattern="[0-9]{4}[-]{1}[0-9]{3}[0-9Xx]{1}";
      document.getElementById("searchword").placeholder="like: 1111-1111 or 1111-111x";
}
 else {
      document.getElementById("searchword").pattern="[A-Za-z]{100}";
    document.getElementById("searchword").placeholder="International journal of Computers and Technology";

}

} }

function inputLimiter(e,allow) { var AllowableCharacters = ''; 函数 inputLimiter(e,allow) { var AllowableCharacters = ''; if (allow == 'Letters'){AllowableCharacters=' ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz';} var k = document.all?parseInt(e.keyCode): parseInt(e.which); if (allow == 'Letters'){AllowableCharacters=' ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz';} var k = document.all?parseInt(e.keyCode): parseInt(e.which); if (k!=13 && k!=8 && k!=0){ if ((e.ctrlKey==false) && (e.altKey==false)) { return (AllowableCharacters.indexOf(String.fromCharCode(k))!=-1); if (k!=13 && k!=8 && k!=0){ if ((e.ctrlKey==false) && (e.altKey==false)) { return (AllowableCharacters.indexOf(String.fromCharCode(k) ))!=-1); } else { return true; } else { 返回真; } } else { return true; } } else { 返回真; } } } }

Check This http://jsfiddle.net/pjkhpxzx/ When A User Select A Value In Drop Down That Value Will Be Visible In The Text Box检查此http://jsfiddle.net/pjkhpxzx/当用户在下拉列表中选择一个值时,该值将在文本框中可见

This Done By A Simple JQuery这是由一个简单的 JQuery 完成的

Below Is HTML下面是 HTML

<select id="data">
    <option value=""></option>
<option value="text">text</option>
<option value="number">number</option>

below is Jquery下面是Jquery

$(document).ready(function(e) {
$("#data").change(function(){
var item = $(this).val();        
  $("#dataval").attr("type",item)
});});

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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