The code is as follows:
Copy Code code as follows:
$ ("#money"). Bind ("PropertyChange", function () {
if (""!=this.value) {
var str = this.value.replace (/(^\s*) | ( \s*$)/g, "");
if (this.value!= str)
This.value = str;
}
if (isNaN (This.value))
This.value = This.value.replace (/[\d]/, ");
});
This uses the Onpropertychange event that jquery binds to the text box with the ID money.
The following code is shielded from the decimal point.
Copy Code code as follows:
$ ("#phone"). Bind ("PropertyChange", function () {
if (""!=this.value) {
var str = this.value.replace (/(^\s*) | ( \s*$)/g, "");
if (this.value!= str)
This.value = str;
}
if (This.value.indexOf ('. ')!=-1) {
This.value = This.value.replace (/[\.) /, '');
This.focus (); }
if (isNaN (This.value)) {
This.value = ($.trim (this.value)). Replace (/[\d]/, ');
This.focus (); } });
Finally, it is best to shield the input method. It can be achieved by css,ime-mode:disabled.
If it is very strict, you can append to the prohibition of pasting and dragging.
no pasting and dragging implementation method
Text boxes prohibit dragging and pasting
The ability to implement text boxes in CSS to prevent dragging and pasting
Create a CSS, as follows:
Copy Code code as follows:
. Textbox_notdragpaste
{
Ondragenter:expression (Ondragenter=function () {return false;});
Onpaste:expression (Onpaste=function () {return false;});
}
If you also need to prohibit the ability to enter Chinese features only need to add a statement.
As follows:
Copy Code code as follows:
. Textbox_notdragpaste
{
ime-mode:disabled;
Ondragenter:expression (Ondragenter=function () {return false;});
Onpaste:expression (Onpaste=function () {return false;});
}