Original: https://www.cnblogs.com/yuanyanbk/p/8269968.html
Do a search function, they often encounter the demand input box checked, the most common is Instant Search, a good summary of what today.
Instant program search:
(1) change event trigger event must meet two conditions:
propertychange, as long as the current object property changes.
Here we use jquery to achieve the effects equivalent to the input placeholder for this property
html
1
2
3
4
|
<
div
class="enterprise-list">
<
label
>银行卡号:</
label
>
<
input
type="text" placeholder="请输入16或19位银行卡号" class="enterprise-inp" id="cartInput">
</
div
>
|
js
1
2
3
4
5
6
7
8
9
|
<
script
>
$(function () {
$("#cartInput").bind('input propertychange',function () {
var text = $("#cartInput").val();
text = text.replace(/[^\d]/g,'');
console.log(text)
})
})
</
script
>
|
With vue write, real-time method can be:
1
|
<
input
type="text" v-model="bankcard" class="enterprise-inp" v-on:input="cartInput">
|
1
2
3
4
|
cartInput:function () {
this.bankcard=this.bankcard.replace(/[^\d]/g,'');
console.log(this.bankcard)
},
|
Do a search function, they often encounter the demand input box checked, the most common is Instant Search, a good summary of what today.
Instant program search:
(1) change event trigger event must meet two conditions:
propertychange, as long as the current object property changes.
Here we use jquery to achieve the effects equivalent to the input placeholder for this property
html
1
2
3
4
|
<
div
class="enterprise-list">
<
label
>银行卡号:</
label
>
<
input
type="text" placeholder="请输入16或19位银行卡号" class="enterprise-inp" id="cartInput">
</
div
>
|
js
1
2
3
4
5
6
7
8
9
|
<
script
>
$(function () {
$("#cartInput").bind('input propertychange',function () {
var text = $("#cartInput").val();
text = text.replace(/[^\d]/g,'');
console.log(text)
})
})
</
script
>
|
With vue write, real-time method can be:
1
|
<
input
type="text" v-model="bankcard" class="enterprise-inp" v-on:input="cartInput">
|
1
2
3
4
|
cartInput:function () {
this.bankcard=this.bankcard.replace(/[^\d]/g,'');
console.log(this.bankcard)
},
|