I want to clear default value of a textbox with jquery.
@Html.TextBox("password", ***@Views.Resource.Password***, new { @class = "cssClass" })
I want to clear default value of a textbox with jquery.
@Html.TextBox("password", ***@Views.Resource.Password***, new { @class = "cssClass" })
use this solution :
$(function (){
$("input.cssClass").val('');
});
or
$(document).ready(function(){
$("input.cssClass").val('');
});
You could use a custom html helper to get the id of the texbox:
public static class HtmlHelperExtensions
{
public static MvcHtmlString ClientIdFor<TModel, TProperty>(this HtmlHelper<TModel> htmlHelper, Expression<Func<TModel, TProperty>> expression)
{
return MvcHtmlString.Create(htmlHelper.ViewContext.ViewData.TemplateInfo.GetFullHtmlFieldId(ExpressionHelper.GetExpressionText(expression)));
}
}
The you could say in the jQuery:
$("#@(Html.ClientIdFor(m => m.Password))").val("");