Number element - Post ID 262232
Why does the number element allow alpha characters to be entered? Is there a way to prevent it?
Hi Ralph.
Sure this can be done.
Add the code below to a html element on your form. Adjust the number1 to your number input name.
Sure this can be done.
Add the code below to a html element on your form. Adjust the number1 to your number input name.
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.2/jquery.min.js"></script>
<script>
var jQ = $.noConflict(true);
jQ(document).ready(function () {
// Change the name to your input name
jQ('input[name="number1"]').keypress(function (e) {
if (e.which != 8 && e.which != 0 && (e.which < 48 || e.which > 57)) {
jQ('input[name="number1"]').after('<span id="error">Numbers only Please!.</span>');
jQ('#error').fadeOut(2000);
return false;
}
});
});
</script>
<script>
var jQ = $.noConflict(true);
jQ(document).ready(function () {
// Change the name to your input name
jQ('input[name="number1"]').keypress(function (e) {
if (e.which != 8 && e.which != 0 && (e.which < 48 || e.which > 57)) {
jQ('input[name="number1"]').after('<span id="error">Numbers only Please!.</span>');
jQ('#error').fadeOut(2000);
return false;
}
});
});
</script>
I can't hear what I'm looking at.
It's easy to overlook something you're not looking for.
This is a site I built for my work.(RSD)
http://esmansgreenhouse.com
This is a site I built for use in my job.(HTML Editor)
https://pestlogbook.com
This is my personal site used for testing and as an easy way to share photos.(RLM imported to RSD)
https://ericrohloff.com
It's easy to overlook something you're not looking for.
This is a site I built for my work.(RSD)
http://esmansgreenhouse.com
This is a site I built for use in my job.(HTML Editor)
https://pestlogbook.com
This is my personal site used for testing and as an easy way to share photos.(RLM imported to RSD)
https://ericrohloff.com
Thanks Eric, that worked just fine
Ralph
Ralph
Have something to add? We’d love to hear it!
You must have an account to participate. Please Sign In Here, then join the conversation.