Do not remove WatermarkText on clicking inside an input field.

Refell Jones asked on March 3, 2020 11:43

Is there a way to have the WatermarkText continue displaying even when the field is in focus?

I see that kentico adds and removes the WatermarkText class on focus and blur.

Recent Answers


vasu yerramsetti answered on March 3, 2020 13:46

You can use Javascript/Jquery for input focus effects while clicking inside the textbox.

reference - https://codepen.io/Takumari85/pen/RaYwpJ

0 votesVote for this answer Mark as a Correct answer

Eric Dugre answered on March 4, 2020 21:09

You could create a custom form control based on the original Text Box form control (~\CMS\CMSFormControls\Basic\TextBoxControl.ascx.cs). In the custom one, you can add a new placeholder attribute to the text box:

protected override void OnLoad(EventArgs e)
{
    base.OnLoad(e);
    TextBox.Attributes.Add("placeholder", "Enter a value");
}

You can add it to the ASCX directly, but doing it in code gives you the opportunity to set it dynamically, e.g. based on FieldInfo.

0 votesVote for this answer Mark as a Correct answer

   Please, sign in to be able to submit a new answer.