Browsing articles in "Javascript / jQuery"
Mar
23

Introducing hooks in the jQuery form validation engine plugin

Hooks are a new feature just introduced into the engine recently. This makes it very easy to add extra behaviors on top of the current error prompts.

The hooks make the use of the jQuery custom event feature. A good example of use would be to add a mention that there is a problem at the form beginning when an error is found.

See the Demo
Download Plugin

There are currently 3 hooks implemented in the engine. One that is triggered before the validation, one after each field validation, and one, finally, with the form result.

* jqv.form.validating : Triggers when the form is submitted and before it starts the validation process
* jqv.field.result(event, field, errorFound, prompText) : Triggers when a field is validated with the result.
* jqv.form.result(event, errorFound) : Trigger when a…


Mar
21

Using form ajax validation with the jQuery Validation Engine plugin

Since 2.0 a lot of people wondered how was working the new ajax validation. Doing ajax validation and controlling the submit form event has always been an headache, and while the validation engine aspire to make it as easy as possible, it is probably never going to be simple for junior developers.

To be fair, the ajax feature has been rewritten and was not as mature as in the 1.7 version. However the 2.x base code is starting to be pretty good with the recent updates. If no other bugs popup, I will start tagging the 2.x releases on github and this version will be considered stable for a while.

There is 2 demos added to the repository, one with only the inline validation and another with…


Jan
24

The iframe cross-domain policy problem

I wrote a small post on Cakemail blog about using iframes, here an excerpt and a link to the full article.

If you are a front-end developer that need to use a cross-domain iframe, you know pain. You could write a nice bit of code and get it working on firefox but it would crash on ie. You would think that would be easy – facebook, twitter and all the others cool kids are doing it! Well, not quite.

Here at Cakemail we are currently building a platform that will enable our users to create forms and embed them in their website directly (think an email list subscription form). So basically, we needed to have javascript control in the parent and in the child.

We had 2 problems…


Jan
17

Form validation engine 2.0 is live

As said previously a rewrite of the validation engine has been in the work for sometimes and today it is finally live, the API changed a lot, might be a good idea to have a look at the new documentation if you are upgrading.

I will be updating the documentation today, but the most up to date doc will always be the readme on github. The legacy 1.7 documentation and download can be found under package when you hit download on github

Time to stop squeezing ketchup (inside joke) and hail to the beast.


Jan
4

Form validation engine 2.0 will be live soon

I will be updating the validation engine to version 2.0 this week, you can have a preview of the beast here. This version is a complete rewrite of the actual code, and mostly all api’s had changes, so if your upgrading, you better have a good look at the documentation (see readme).

The rewrite was done by Olivier Refalo, I wanted to do a rewrite for some times but a lack of time and passion about this stopped me. The script was near 3 years old and while I was happy with it, to stay in a “modern” javascript world it needed significant changes.

The core of the library stayed the same, but what is wrapping is a lot better, Olivier also did a nice rewrite of…


Jan
3

Printing web pages & a new jQuery print plugin

Printing is becoming more and more obsolete these days, however most websites still do offer a print stylesheet . Print stylesheets are rarely perfect, when you start disabling some parts of your website you’re bound to forget to disable a div and your layout will probably give you an headache.

Making a site print friendly

There is generally 2 way used for making a website print friendly. Your first option is to use the technique I’ve talked before and make a print stylesheet directly in your website, and you disable everything that is not relevant content.

Generally it becomes rapidly a mess, unfortunately disabling every parts of your website can be tedious, and you are at the mercy of odd IE behaviors because of divs multiplication, css float…


Dec
3

stackJS, a javascript module loader and dependencies handler

Writing good and maintainable javascript is hard, especially when your first javascript framework was jQuery. Couples of years ago, you could be ok using document.ready for implementing your minimal features. Now not so much, web application use more and more javascript, and there comes a time where using anonymous functions with a ton of events is just not enough. jQuery is pretty good at handling everything cross-browser, but is does nothing to help you implement a clean architecture and rectifying that is the basic idea behind stackJS.

Most of you guys are probably aware that some frameworks have popped up to fill this blank, like the excellent javascriptMVC (a jQuery MVC framework), another good example would be backbone.js. I really like what javascriptMVC has to offer, it’s…


Nov
11

Managing string localization in javascript files

One thing that is really frustrating to deal with is localization. There is nothing funny about localizing text from your application. But this is a necessary step when you want to go for very a broad market in multiple languages. So while your there, why not having a localization infrastructure in all your front-end.

Most PHP frameworks and JS widget libraries can now be easily customized as far as localization is concerned. However your bound to have some string messages in your javascript modules. Not thinking about the localization of these little pesky messages leads to painful hours of looking through every files to find some strings that have not been localized.

Consolidating your localization architecture

Okay your widget has 2 or 3 files, each for one…


Nov
1

Managing undefined properties on multiple level in objects in javascript

When you’re working with objects you often need to know if a properties already exists in an object, for doing that there is 2 solutions that are already working fairly well. But when you look for undefined properties on multiple levels, it rapidly becomes a mess.

An example

  1. if(typeof object.props1.props2 == "undefined"){
  2. // do stuff
  3. }

If props1 is undefined, unfortunately your browser is going to throw you that object.props1 is undefined.

Rewinding a bit

First, let’s take a look at your options if your only working on one level, let’s say you want to know if prop1 exists in an object

First solution:

  1. if(object.hasOwnProperty("props1") ){
  2.  // Do stuff
  3. }

It is pretty self exploratory, it looks in the object if it’s got the property props1, however it is not going to…


Oct
20

Validation Engine 1.7.1 compatibility release and why

I just released a compatibility release for jQuery 1.4.3.

Unfortunately jQuery 1.4.3 has a bug when using live with attribute not equal selector in Firefox, and this is exactly what I use in my validation engine.

I also moved my code to github, why? Because Github is hot.

http://github.com/posabsolute/jQuery-Validation-Engine


RSSSome Tweets