I want to send an information through a form, however I do not want it to appear in a field, that is, I want to send information via post, but it does not appear in input
. How to do this?
I want to send an information through a form, however I do not want it to appear in a field, that is, I want to send information via post, but it does not appear in input
. How to do this?
In input, set the hidden
attribute and place the value within value
, like this:
<input type="hidden" name="input1" value="valor que você quer passar">
Maybe it's not your case, but if you're doing this to implement the honeypot , where you put a hidden field to identify that your user is actually a bot spammer, input type="hidden"
would not be the best form, since it is trivial for a bot to identify that field should not be filled in.
Other ways to do this are:
in JavaScript:
document.querySelector('input[name="NAME"]')[0].style.visibility = 'hidden';
or
document.querySelector('input[name="NAME"]')[0].style.display = 'none';
in jQuery:
$('input[name="NAME"]').hide();
in CSS:
input[name="NAME"] {
display: none;
}
Yes, a bot that has a JavaScript and CSS parser will also be able to identify that the input should not be filled in, but the above method already prevents simple bots from spamming your site.