asp.net mvc 2 - JQuery validation based on class? -


I have a form that has dynamically created elements, one of those date types will be on my form There may be many fields of this type, all of which are valid.

I am using a properly typed sequence in asp mvc, so the name will change based on various factors. I am valid on the basis of class name instead, because it will be stable for that type of field.

Ie:

  & lt;% = html .textbox ("question greetings [" + index + "]. Reply", qa.AnswerValue, new {@class = "DateTypeClass"})%>  

Then I will need JQuery validation based on the classname DateTypeClass versus the name.

Any thoughts?

You can check the value in your verification job:

  Var dateFieldValue = $ (".DateTypeClass") Val () .; // valid dateFieldValue here  

Additionally you do not need to select by class if you do not want to. If any other fields do not share this validation, you can choose from jquery partial ID. It will look like this:

  var dateFieldValue = $ ("[id ^ = someId]"). Val (); // validate dateFieldValue here  

So if you set some ID on the field and adds some extra stuff to ASP.NET ID then it will still select it properly. I am not using ASP.NET MVC, so I know that you are setting ID (if at all) then

In addition to this, if you want inline verification, Waiver the event:

$ ("DateTypeClass"). Blur (function () {// call field verification function here});

Comments

Popular posts from this blog

Eclipse CDT variable colors in editor -

AJAX doesn't send POST query -

wpf - Custom Message Box Advice -