Only allow input number value with autoNumeric.js - The Koch Family
The Koch Family The Koch Family

Latest news

جاري التحميل ...

Only allow input number value with autoNumeric.js


autoNumeric is a jQuery plugin that automatically formats currency and numbers as you type on form inputs. I used autoNumeric 1.9.21 for demo code.

1. Dowload autoNumeric.js file from https://github.com/BobKnothe/autoNumeric
2. Import to project
 
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.11.0/jquery.min.js"></script>
<script type="text/javascript" src="js/autoNumeric.js"></script>
3. Define a function to use it
 
<script type="text/javascript">
/* only number is accepted */
function txtNumberOnly_Mask() {
var inputOrgNumber = $("#numberTxt");
inputOrgNumber.each(function() {
$(this).autoNumeric({
aSep : '',
aDec: '.',
vMin : '0.00'
});
});
}
</script>

4. Call the function by event
 
<form>

<input type="text" value="" id="numberTxt"/>(only number)

</form>

<script type="text/javascript">

$(document).ready(function (){

txtNumberOnly_Mask();

});

</script>

Comments



If you like the content of our blog, we hope to stay in constant communication, just enter your email to subscribe to the blog's express mail to receive new blog updates, and you can send a message by clicking on the button next ...

إتصل بنا

About the site

author The Koch Family <<  Welcome! I'm so glad that you stopped by Your Modern Family blog. Together, we will talk about raising kids, organizing the home and saving money! and Tips & tricks and more…

< Learn more ←

Blog stats

Sparkline 2513183

All Copyrights Reserved

The Koch Family

2020