Jump to content

Código de restrição de senha


Recommended Posts

Se quiser só letras e números para um input de senha, pode fazer assim no HTML

<input type="text" pattern="[a-zA-Z0-9]{5,6}" name="" value="" placeholder="5 à 6 caracteres" required />
<input type="submit">

E assim no PHP

$string = $_POST['input_tal'];
if(!preg_match("/^([a-zA-Z0-9]+)$/i",$string) || strlen($string) < 5 || strlen($string) > 6) {
echo "texto incorreto";
} else {
echo "texto correto";
Edited by apocsantos
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

  • Create New...

Important Information

By using this site you accept our Terms of Use and Privacy Policy. We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.