Textbox value

Is it possible to hide textbox value by CSS and HTML or Js?

There is a hidden input type which will not show in the browser.
Other input types can be made not to display using css: display: none
But with both methods it will only be hidden in the browser display, it will still be visible in the html source code which anyone could view if they want.

Ok, not possible to hide value of textbox like;

<Input type="text" name="name" value="hide-me"/>

??

The two ways I mention:-

<input type="hidden" name="inputname" value="inputvalue"> <!-- hidden input -->

<input type="text" name="inputname" value="inputvalue" class="hidden"> <!-- hidden via css -->

The second example requires the css:-

.hidden { display; none; }

But your code is hide box too… But we want hide value of textbox.

Sam’s 2nd option IS a textbox!

Maybe what Shiv is saying is that he wants the text within the input hidden but not the input itself. Am I correct?

If so, Shiv, you have to ask WHY you need to do this.

  1. if is just to pass a value then you should use <input type="hidden" >. Please note that using CSS properties such as "display:none;" has the side effect of keeping the elements value from being sent when the form is submitted

  2. If you want a level of privacy when entering text into he text box, you should be using <input type="password">, it covers up the text that is being input, but at the same time lets the user know he is actively entering characters

  3. Blindly hiding the text from the user seems to me like it would be a usability nightmare. How would the user know he is entering text into the input? So tho it can be done this way, i highly recommend against it. In any case you could probably accomplish this simply by: input{ color:transparent;} /*( or match the color to background)*/

hope that helps

1 Like

That is the question.

Are you sure about that?
In my experience that is not the case.

1 Like

This code

<input type="text"value="<?php echo $_SERVER["REMOTE_ADDRESS"]; ?>/>

does not use the correct $_SERVER element, but this code

<p>Your IP Address: <?php echo $_SERVER['REMOTE_ADDR'];?></p>

does.

(I am reading the question as “why does my first bit of code not put the IP address into the text box, but if I just echo it with the second bit of code, it’s fine”. That might be wrong, I don’t understand how it got onto hiding anything.)

Please don’t change the question in the opening post after it has been answered.
It causes confusion as the answers given no longer make any sense in the context of the new question.

If you do have a completely new question to ask start a new topic.
If you have a related or similar question taking the existing topic in a new direction, make a new post with the revised question.

I have reverted to your original post which was in the HTML & CSS forum and quoted the edited post here for context of the post edit answers.

2 Likes

Ok…I understand

1 Like

SamA74, I stand corrected. I was thinking of the ‘disabled’ attribute. Thank you.

1 Like

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.