ASP MVC Razor encode special characters in input placeholder

I think this post will help you: HTML encode decode c# MVC4 I think there are other ways to get this behaviour, but this is one option of using the TextBox: @Html.TextBox(“CompanyName”, HttpUtility.HtmlEncode(“Your company's name”)) There is also HttpUtility.HtmlDecode, which might help with our save action. update if you wrap HttpUtility.HtmlDecode around your place holder: … Read more

Change an HTML input’s placeholder color with CSS

Implementation There are three different implementations: pseudo-elements, pseudo-classes, and nothing. WebKit, Blink (Safari, Google Chrome, Opera 15+) and Microsoft Edge are using a pseudo-element: ::-webkit-input-placeholder. [Ref] Mozilla Firefox 4 to 18 is using a pseudo-class: :-moz-placeholder (one colon). [Ref] Mozilla Firefox 19+ is using a pseudo-element: ::-moz-placeholder, but the old selector will still work for … Read more

Add span inside form’s placeholder

Here is pure css solution IE10+ .input-placeholder { position: relative; } .input-placeholder input { padding: 10px; font-size: 25px; } .input-placeholder input:valid + .placeholder { display: none; } .placeholder { position: absolute; pointer-events: none; top: 0; bottom: 0; height: 25px; font-size: 25px; left: 10px; margin: auto; color: #ccc; } .placeholder span { color: red; } <form … Read more

Java – placeholder on textfield

I found this on the oracle forums. public class TextFieldWithPrompt extends JTextField{ @Override protected void paintComponent(java.awt.Graphics g) { super.paintComponent(g); if(getText().isEmpty() && ! (FocusManager.getCurrentKeyboardFocusManager().getFocusOwner() == this)){ Graphics2D g2 = (Graphics2D)g.create(); g2.setBackground(Color.gray); g2.setFont(getFont().deriveFont(Font.ITALIC)); g2.drawString(“zip”, 5, 10); //figure out x, y from font’s FontMetrics and size of component. g2.dispose(); } } https://forums.oracle.com/forums/thread.jspa?threadID=1349874