problem filling out form with capital letters

0

personal in my site the user when he is going to register in my site the fields where he type text he can type in uppercase and this generates a BUG on my site there in the panel would like to know if there is any validator that does not allow the user to type uppercase because he has to fill the entire form with only lowercase letters.

    
asked by anonymous 09.06.2017 / 14:29

3 answers

2

Before adding to your database, convert the string to lowercase. I put the down-to-top example of how to convert PHP and Java Script to lowercase.

In PHP:

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

In Javascript:

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

To force the field to always be lowercase, 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 its input, put onkeyup="return lowerCase(this)" .

    
09.06.2017 / 14:33
1

You can use strtolower and convert, before sending to the 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>
    
09.06.2017 / 14:32
1

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

However, there is mb_strtolower() which allows you to reasonably change the characters, but it is very slow .

In this case things like:

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

It 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:

ᾨ
Ⅻ
    
09.06.2017 / 15:36