Your Awesome Social Network

(Needs Harmony, tested only on Firefox at the moment)
Register
Nickname (triggers ajax, try with zack)
First Name
Last Name
E-mail
Password
Re-type password, just for science
Sign Up

Chained Browser Demo

This demo shows a form validation DSL implemented with Chained in Coffeescript:

form '#form', ( check ) ->

    field '#fname', (f) -> 
        check(f.value).isNotNull().isLengthAtLeast(of: 2).show(f)

    field '#lname', (f) -> 
        check(f.value).isNotNull().isLengthAtLeast(of: 2).show(f)

    field '#uname', (f) -> check(f.value).isNotNull().userNameShouldNotExist(msg: 'User already exists').show(f)

    field '#password1', (f) ->
        check(f.value).isNotNull().isLengthAtLeast(of: 4).show(f)

    field '#password2', (f) ->
        check(f.value).isNotNull().shouldMatchElement(element: '#password1', msg: "passwords should match").show(f)
  • form and field functions setup focusout callbacks. check is an alias for chained._.

  • The method show renders popup error messages whenever one of the promise associated with a predicate-chain fails.

  • The method userNameShouldNotExist is based on an Ajax get and, as such, is promise based. Chained allows to use the result in the next predicate as if it were synchronous. The users file at the moment contains only the user zack.