problem filling in form with uppercase letters

Asked

Viewed 1,036 times

0

staff in my website the user when will register in my site the fields where he types text he can type with capital letters and this generates a BUG on my site there in the panel I would like to know if there is any validator that does not allow the user to type capital letters because he has to fill the whole form only with lower case letters.

3 answers

2

Before adding to your database, convert the string to lowercase. I put the short example of how to convert in PHP and Java Script to lowercase (minute letters).

In PHP:

$string = "TESTE";
echo strtolower($string); //teste

Javascript:

var string = "TESTE";
console.log(string.toLowerCase()); // teste

To force the field to always be minuscule letters, it would look like this:

// Função javascript
function lowerCase(input) {
  input.value = input.value.toLowerCase();
}
Tente digitar letras maiúsculas:
<input type="text" id="txt" onkeyup="return lowerCase(this)" />​

I improved the above example. You need to put this javascript function in a . js file and in its input, put onkeyup="return lowerCase(this)".

  • Thank you for the javascript response as I insert this into an input text for example

  • I saw your next friend response this way that you did not display on time to the user ? i wanted a way that already displayed itself to it all minuscule in the form not convert at the time of saving it would have to see the letters be written in lowercase even with the Capslock turned on

  • I edited my answer, Kirito, see if it works.

1

Can use strtolower and convert, before sending to database. strtolower

EDITED


<script type="text/javascript">
// INICIO
function minuscula(a){
v = a.value.toLowerCase();
a.value = v;
}
//FIM
</script>
Como usar
<label>Nome:
<input name="nome" type="text" id="nome" size="50" onkeyup="minuscula(this)" />
</label>

1

I think the ideal would be to actually fix the "this generates a BUG on my site there in the panel" and to support the uppercase characters normally.

Meanwhile there is the mb_strtolower() which reasonably allows the characters to be minuscule, but he’s very slow.


In that case things like:

Inkeliz
ÍnkÊlÍz
ĮŇЌẸĹĮŻ

Will result in:

inkeliz
ínkêlíz
įňќẹĺįż

But, this is not perfect, because not everything has tiny characters (?) or the function simply ignores, as in the cases:

ᾨ
Ⅻ

Browser other questions tagged

You are not signed in. Login or sign up in order to post.