2
I have the following field:
<input type="number" name="teste_senha">
I need that, when typing some content, this content is replaced by ****, without losing its original content, can be stored in a field Hidden.
How do I get this result?
2
I have the following field:
<input type="number" name="teste_senha">
I need that, when typing some content, this content is replaced by ****, without losing its original content, can be stored in a field Hidden.
How do I get this result?
5
As they said, it doesn’t make much sense what you want, is to have more work for nothing. HTML already has its own attribute to hide passwords with asterisks: type="password"
.
What you can do if you just want numbers on input
, is to do a validation via Javascript. Using regex would be an option:
function validar(){
if( /^[0-9]*$/.test($("#campo").val()) && $("#campo").val()){
alert("Ok!");
}else{
alert("Erro! Só são permitidos números");
}
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<input id="campo" type="password" name="teste_senha">
<br />
<input type="button" value="Verificar" onclick="validar()">
Browser other questions tagged jquery
You are not signed in. Login or sign up in order to post.
you’ve already tried something?
– Leandro RR
No. Not yet
– Sr. André Baill
but you want to hide and show this content through a user action?
– Leandro RR
Exactly, actually, my idea is in the mobile version, in the password field, accept only NUMBERS, then I thought to do so, mount as type number, and mask when typing...
– Sr. André Baill
As I understand it, you want to replace the characters with **** while the user fills in the field, correct? if yes, you have to create an Hidden input yourself, and use the "change" javascript event to see changes in the input, or use the keyup
– Leandro RR
No, you don’t have to use the
hidden
. If the field is a password, use the typepassword
and validate with JS. What you’re asking for is gambiarra. Read about the attributepattern
of HTML 5.– Woss