.net - HTML Helper/Text Box validation -


i have input on view:

<%= html.textboxcurrentdatewithoutpermission("effectivedate", model.effectivedate.hasvalue ? model.effectivedate.value.tostring("dd-mmm-yyyy") : "", new string[] { permissions.hasicadvanced }, new { @class = "economictextbox", propertyname = "effectivedate", onchange = "parseandsetdt(this); ", datatype = "date" })%> 

here custom html helper:

public static mvchtmlstring textboxcurrentdatewithoutpermission(                                                           htmlhelper htmlhelper,                                                           string name,                                                           object value,                                                           string[] permissions,                                                           object htmlattributes                                                          )         {             foreach (string permission in permissions)             {                 if (chatham.web.ui.extranet.sessionmanager.displayuser.isinrole(permission))                 {                     // user has permission => render textbox                     return htmlhelper.textbox(name, value, htmlattributes);                 }             }              // user has no permission => render readonly checkbox             var mergedhtmlattributes = new routevaluedictionary(htmlattributes);             mergedhtmlattributes["disabled"] = "disabled";             return htmlhelper.textbox(name, value == "" ? datetime.now : value, mergedhtmlattributes);         } 

the way works is, when user not have permission passed in, box disabled.

the way needs -- if user not have permission passed in, needs enabled, dates can accept todays date , dates in future.

so need jquery validation (or plain js), textbox on page following case:

if textbox enabled , user not have permission, allow user input current date or future dates only.

ended using jquery's .validate() method.


Comments

Popular posts from this blog

apache - Add omitted ? to URLs -

redirect - bbPress Forum - rewrite to wwww.mysite prohibits login -

php - How can I stop spam on my custom forum/blog? -