jquery - Validate HTML Textbox -


i have textbox:

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

i need js validation help. if user has permission, can enter date. if user doesn't, can enter present date, or dates in future.

here controller method have can if user has permission or not.

[nocache]         public actionresult hasadvanced()         {             if (chatham.web.ui.extranet.sessionmanager.displayuser.isinrole("hasicadvanced"))             {                 return json(                 new                 {                     value = "true"                 });             }             else{                 return json(                 new                 {                     value = "false"                 });             }         } 

what js/jquery like? i'm soooo stumped.

thanks!

if use jquery validation take @ remote rule.

and might end looking this:

$("#myform").validate({   rules: {     effectivedate: {       required: true,       remote: "hasadvanced"     }   } }); 

if not want use existing framework roll own validation 1 field.

$("#effectivedate").blur(function(){   //or $.get   $.post("hasadvanced", null, function(data){     //handle json data , update field display message, etc......   }, "json"); }); 

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? -