I have an onclick handler which executes and jquery ajax load function but I need to validate a form first before executing the load function. I don't know how to prevent the load from occurring until the validate is complete. I am validating using the jquery validate plugin. Any ideas?

thanks

Paul_Wilkins
—
2011-04-02T22:34:14Z —
#2

silversurfer5150 said:

I don't know how to prevent the load from occurring until the validate is complete. I am validating using the jquery validate plugin. Any ideas?

The jQuery validate documentation page has a section called "Plugin Methods". At the top of that list of methods is one called "validate( options )" that you can click on to get more details.

The "validate( options )" page has two tabbed sections, called Overview and Options.

In the Options tab is one called submitHandler which shows some code to achieve what looks to be precisely what you need.

silversurfer5150
—
2011-04-03T13:00:09Z —
#3

Hey there,

Thanks for pointing me in the right direction, got it sorted :). I have been working on an opencart mod.

The fact that a bit cms system like opencart relies on ajax for its checkout funcion showed me that a lot of people aren't considering users with js disabled nowadays and I have always learnt that I should take this into consideration.

I can see that you're a very experienced js developer, what do you think?

Paul_Wilkins
—
2011-04-03T13:06:06Z —
#4

silversurfer5150 said:

I can see that you're a very experienced js developer, what do you think?

Thanks.

My belief is that JavaScript should be used to enhance web pages. When scripting is used to supply behaviour that has no alternative means of occurring, that tends to lead to bad places.

So how a CMS should handle that, is to use standard basic form submissions to do the work, and then to use JavaScript to take over the form submission in order to provide an enhanced user experience, in this case that being to submit using ajax so that a page reload is not needed.

silversurfer5150
—
2011-04-03T14:31:15Z —
#5

Thanks I really appreciate the advice.

BTW how do you debug your scripts? I have been using firebug and console.log() to dump variables but I would like to learn how to trace through properly, I have tried the Venkman debugger and can't seem to get it to work. Do you know of any good tutorials on tracing though with either Venkman or firebug or anything similar?

thanks

Silversurfer

Paul_Wilkins
—
2011-04-04T01:37:53Z —
#6

silversurfer5150 said:

BTW how do you debug your scripts?

I debug them using the built-in debugger that comes with Google Chrome.

silversurfer5150 said:

I have been using firebug and console.log() to dump variables but I would like to learn how to trace through properly, I have tried the Venkman debugger and can't seem to get it to work. Do you know of any good tutorials on tracing though with either Venkman or firebug or anything similar?