4

I have multiple section is asp.net that submits data in chunk and i want to use jquery validation plugin, but issue is that asp.net wraps everything in form and child forms not wokring right and technically incorrect.

So only alternative is forget about form and implement validation for divs. But all sames i see are using form. As not being not good at jquery i can't figure out how to use this validator on section of page(On div).

Is it possible? or any other good alternative?

Source: http://bassistance.de/jquery-plugins/jquery-plugin-validation/

1
  • Thanks for all responses i have switched application to MVC to get more control and clean html Commented Aug 6, 2009 at 20:03

3 Answers 3

1

I am using bassistance jquery plugin that you mentioned above, and it doesnt require form submmission to do validation. it just validated after "on blur" event triggered.

or if you want to validate it manually you can call like : $("#commentForm").validate(); (read on this doc page [http://docs.jquery.com/Plugins/Validation][1])

Sign up to request clarification or add additional context in comments.

Comments

1

In one of my pages I have a div that is sumitted back via Java and Ajax. Prior to submitting, I validate the individual fields using .validate().element( "#myelement" ); I do it all in javascript though, and don't rely at all on the built in automagic asp controls.

I hate to say it, but that global form issue is your real problem. It's probably not an option, but if it is, look as switching to asp.net MVC.

1 Comment

Thanks for your response i have switched application to MVC to get more control and clean html
0

Like nightingale2k1 said, you should be able to use that plug-in just fine with a FORM. Here's a quick example that uses a DIV instead:

<div id="pseudoForm">
  <input type="text" name="first_name"/>
  <input type="text" name="last_name"/>
</div>
<script type="text/javascript">
  $("#pseudoForm").validate({
    onfocusout:true,
    rules:{
      first_name:"required",
      last_name:"required"
    });
</script>

Notice how I used "onfocusout:true", which will make the plug-in validate when the user de-selects either element. You'll need to either use something like that, or else hook up your own event (probably in response to a button press) for the validation to be triggered, as the normal trigger (onSubmit) isn't applicable to DIVs.

5 Comments

if I do that I get "validator in undefined" on FF, "'settings' is null or not an object" on IE, "Cannot read property 'settings' of undefined" on chrome. What up?
Sounds like a problem with the validation plug-in; you'll really need a new SO question, with lots of details and code examples from your specific setup, for anyone to provide meaningful help.
This isn't an answer, don't know why it is marked as accepted as it wont work.
this solution is not working. can anyone provide a working solution.
-1, This answer needs to be deleted. The plugin does not work like this and the onfocusout option is enabled by default. jsfiddle.net/Y4h2v

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.