js control text box to enter only Chinese, English, numbers and special symbols specified.
Reprinted https://www.cnblogs.com/jingliwufadaodai/p/5756018.html#4434038
The input string input box containing Chinese into English comma comma
var str = $("#keywords").val();
str=str.replace(/,/ig,',');
$("#keywords").val(str);
});
var obj = document.getElementByIdx_x(”testSelect”); //定位id
var index = obj.selectedIndex; // Select Index
var text = obj.options [index] .text; // selected text
var value = obj.options [index] .value; // selected value
jQuery select select values obtained
The first way
$ ( '# testSelect option: selected '). Text (); // selected text
$ ( '# TestSelect option: selected') .val (); // selected values
$("#testSelect ").get(0).selectedIndex;//索引
Scene: drop-down box when the text value is changed, you want to get selected
$("#testSelect").change(function(){
alert($('#testSelect option:selected').text());
});
The second approach
$ ( "# tesetSelect") find .. ( "Option: selected") text (); // selected text
...... .val ();
...... .get (0) .selectedIndex;
all in all:
First input '<input>' li
onkeyup="value=value.replace(/[^\X]/g,'')"
Then in X (/ [\ X] / g, '') in the code that you want to enter into it,
Chinese u4E00-u9FA5, 0-9, English az \ AZ, other symbols @, dots or other symbols.
It can also be multiple, with \ separated on the line.
For example: the @ symbol alphabet + number + + dot notation \ a- \ z \ A- \ Z0-9 \ u4E00- \ u9FA5 \ @ \
To pop-up menu and the right information can not paste the copied text into the box if
Needs to be entered onpaste = "return false" oncontextmenu = "return false;" in '<input>' li
'S Control Box only numbers
<input onkeyup = "value = value.replace (/ [^ 0-9] / g,' ')" onpaste = "value = value.replace (/ [^ 0-9] / G, '') "the oncontextmenu =" value = value.replace (/ [^ 0-9] / G, '') ">
the JS control box only numbers, decimal
<input onkeyup =" value = value . replace (/ [^ \ 0-9 \ .] / g, '') "onpaste =" value = value.replace (/ [^ \ 0-9 \.] / g, '') "oncontextmenu =" value = value.replace (/ [^ \ 0-9 \.] / G, '') ">
the JS control input only the English text box
<input onkeyup =" value = value.replace (/ [^ \ a- \ z \ A- \ Z] / g, ' ') "onpaste =" value = value.replace (/ [^ \ a- \ z \ A- \ Z] / g, '') "oncontextmenu =" value = value.replace (/ [^ \ A- \ Z \ A- \ the Z] / G, '') ">
the JS control box can only enter English text, numbers
<input onkeyup =" value = value .replace (/ [^ \ a- \ z \ A- \ Z0-9] / g, '') "onpaste =" value = value.replace (/ [^ \ a- \ z \ A- \ Z0-9] / G, '') "the oncontextmenu =" value = value.replace (/ [^ \ A- \ Z \ A- \ Z0-9] / G, '') ">
the JS Chinese input a text box control
<input onkeyup = "value = value.replace (/ [^ \ u4E00- \ u9FA5] / g, '')" onpaste = "value = value.replace (/ [^ \ u4E00- \ u9FA5] / g, '' ) "the oncontextmenu =" value = value.replace (/ [^ \ u4E00- \ u9FA5] / G, '') ">
the JS a text box control input Chinese, English, numbers
<input onkeyup =" value = value.replace (/ [^ \ a- \ z \ A- \ Z0-9 \ u4E00- \ u9FA5] / g, '') "onpaste =" value = value.replace (/ [^ \ a- \ z \ A- \ Z0-9 \ u4E00- \ u9FA5] / g , '') "oncontextmenu =" value = value.replace (/ [^ \ a- \ z \ A- \ Z0-9 \ u4E00- \ u9FA5] / g, ' ') ">
the JS a text box control input Chinese, English, numbers, spaces
<input onkeyup =" value = value.replace (/ [^ \ a- \ z \ A- \ Z0-9 \ u4E00- \ u9FA5 \ ] / g, '') " onpaste =" value = value.replace (/ [^ \ a- \ z \ A- \ Z0-9 \ u4E00- \ u9FA5 \] / g, '') "oncontextmenu =" value = value.Replace (/ [^ \ A- \ Z \ A- \ Z0-9 \ u4E00- \ u9FA5 \] / G, '') ">
the JS a text box control input Chinese, English, numbers, decimal
<input onkeyup="value=value.replace(/[^\a-\z\A-\Z0-9\u4E00-\u9FA5\.]/g,'')" onpaste="value=value.replace(/[^\a-\z\A-\Z0-9\u4E00-\u9FA5\.]/g,'')" oncontextmenu = "value=value.replace(/[^\a-\z\A-\Z0-9\u4E00-\u9FA5\.]/g,'')">