Reputation:
I tried to use oninput event twice but it gives me an error as you can see following.
<input id="Input1" type="text" oninput="myFunction()" oninput="this.value = this.value.replace(/[^0-9.]/g, '').replace(/(\..*)\./g, '$1');"/>
So how to use more than one function in one event?
Upvotes: 1
Views: 51
Reputation: 1
You can include the code at the second oninput
event attribute following the call to myFunction()
at the first input
event attribute
<script>
function myFunction() {console.log("myFunction")}
</script>
<input id="Input1" type="text" oninput="myFunction(); this.value = this.value.replace(/[^0-9.]/g, '').replace(/(\..*)\./g, '$1')"/>
Upvotes: 0
Reputation: 222720
Place the logic inside the function itself
myFunction(){
//whatever existing logic
this.value = this.value.replace(/[^0-9.]/g, '').replace(/(\..*)\./g, '$1');
}
or create another function for the logic and use ;
<input id="Input1" type="text" oninput="myFunction();mysecondFunction()"/>
Upvotes: 1