开发者

jQuery form validation event with pop-up resizing query

开发者 https://www.devze.com 2023-04-10 11:25 出处:网络
I\'m currently showing the user a pop-up form - http://colorpowered.com/colorbox/ - which so far seems to be the only one i\'ve found compatible with all browsers (Round of applause to IE for not been

I'm currently showing the user a pop-up form - http://colorpowered.com/colorbox/ - which so far seems to be the only one i've found compatible with all browsers (Round of applause to IE for not been compatible in other ones).

I'm also using with this the jQuery form validation engine - https://github.com/posabsolute/jQuery-Validation-Engine to help ensure all fields are complete.

I have set out to - When the user clicks submit and all validation is passed, for them to be redirected to another window saying thank you etc.. The problem is, this is a smaller window and so I needed to resize it, which I have successfully, but regardlous of if they've passed the validation or not.

The code that works to resize the pop-up is:

function resize() {
    $.colorbox.resize({innerWidth:432, innerHeight:280});
};

With the "onclick" event attached to the submit button -

onclick="top.resize()"

Now i've taken a look at the examples the validator gives to see if I can return True or False should the form validation be passed, I managed to find this in the form of an alert:

<a href="#" onclick="alert('is the form valid?'+jQuery('#formID').validationEngine('validate'))">Evaluate form</a>

Now I thought I could replicate this into my code to only run the 'Resize' if the validation passes (When the resize runs and the validation hasn't been passed, the form skews and disorientates within it). This is my end result so far but to no avail:

function resize() {
    if($('#jobForm').validationEngine('validate')) == 开发者_如何转开发'true'){
    $.colorbox.resize({innerWidth:432, innerHeight:280});
}
}; 

Within the console, the error i get is 'Uncaught SyntaxError: Unexpected token ==' but i'm sure this just isn't the problem.

This is where i hit a grey area and any advice would be hugely appreciated.

Many thanks in advance.


This line is indeed incorrect, your parens are unbalanced:

if($('#jobForm').validationEngine('validate')) == 'true'){

Change it to this, and see if your problem goes away:

if($('#jobForm').validationEngine('validate') == 'true'){
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号