1
I am making a data entry site in the database and I do not want it to be possible to insert the euro "€" symbol in the input. Is there any way to block it?
1
I am making a data entry site in the database and I do not want it to be possible to insert the euro "€" symbol in the input. Is there any way to block it?
1
Yes, you can initially do a check using Javascript, and for security another check in the imperative language in which you are creating your site, type PHP, Ruby, Python, before recording in the database.
To check in Javascript, simply modify the type of the submit button, from "Submit" to "button" and add an event by clicking to execute a Javascript function in which you will check the presence of the "€" symbol before submitting.
In PHP before writing to the database it is highly advisable to check again.
and can help me with code? I just don’t know how...
0
Put this in your code, This code eliminates the symbol €, for example:
1,43€ is 1,43€
But make sure that when doing the Insert in the BD uses the result variable.
<script>
function myFunction() {
var str = "a sua variavel aqui";
var patt1 = /[^€]/gi;
var result = str.match(patt1);
}
</script>
is not working
0
this solves and also prevents writing letters
function allowOnlyNumbers(e) {
var tecla = (window.event) ? event.keyCode : e.which;
if ((tecla > 47 && tecla < 58)) return true;
else {
if (tecla == 8 || tecla == 0) return true;
else return false;
}};
i<input id="input" type="number" onkeypress="return allowOnlyNumbers(event)"/>
Browser other questions tagged html
You are not signed in. Login or sign up in order to post.
<input type='number' step='0.01'>
already helps, but you should check the server side later– Miguel