문제

I want to use the 'validate' method that is included jquery validation engine plugin, whilst also be able to pass in a few available options to ensure that the validation errors show in the correct way, such as the 'promptPosition' option.

Due to the nature of the framework that I am using which is Meteor.js, I cannot use the default submit functionality to submit a form, nor can I use Ajax straight off the bat. I would have to override default submit functionality, validate the form, then do the manipulations that I need to do to the backend, which is in javascript.

Is it possible to do something like this with this plugin?

$('form').validationEngine('validate', {promptPosition: 'topLeft' });

I know that you can just use: $('form').validationEngine('validate') but I do need some the plugin's custom options available similar when you use the 'attach' method.

Cheers.

도움이 되었습니까?

해결책

I isn't possible to define options when calling validate. The only solution I can think of is to use something like this:

var myForm = $("form");  
myForm.validationEngine('attach', {promptPosition : "topLeft"});
// other js... 
// when you want to validate the form use:
myForm.validationEngine('validate');

You set the desired options when "attaching" the validation engine. You then trigger the validation manually. To prevent the validation getting triggered by the user just use a button instead of input type="submit".

Here's a demo of what I'm trying to explain: http://jsfiddle.net/jxWp8/2/

다른 팁

yes it is possible:

you can look at line 35 at this code for it specifically.

https://github.com/carlo379/bitstarter/blob/master/assets/js/toolspin.js

and you can view that form works in http://www.toolspin.com

it's how he implemented it for our school project

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top