Greetings, I need a text entry (text input) like:
<input type="text" id="txtNombre" name="txtNombre" value="" placeholder="Ej: Juan" required="" />
Do not let me put '. ' and ', '
Greetings, I need a text entry (text input) like:
<input type="text" id="txtNombre" name="txtNombre" value="" placeholder="Ej: Juan" required="" />
Do not let me put '. ' and ', '
In vanilla JS:
function noPuntoComa( event ) {
var e = event || window.event;
var key = e.keyCode || e.which;
if ( key === 110 || key === 190 || key === 188 ) {
e.preventDefault();
}
}
<input type="text" onkeydown="noPuntoComa( event )">
Breakdown KeyCode
:
110
- Point on the left keyboard 190
- Point on the right keyboard 188
- Coma Good friend you can use the library Mask and weigh it as a parameter a regular expression.
Regular expression
/[^.,]/
This expression tells us that you can enter any character except the .
and the ,
Functional example
$("#txtNombre").mask('ZZ',{translation: {'Z': {pattern: /[^.,]/, recursive: true}}});
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery.mask/1.14.13/jquery.mask.min.js"></script>
<input type="text" id="txtNombre" name="txtNombre" value="" placeholder="Ej: Juan" required="" />
I hope it is what you are looking for greetings.