realtime-validations rails gem

There is a new gem in the Rails world: realtime-validations.

It provides automatic realtime validations on your forms based on the validations set on the model.

The idea is to ask on every ‘blur’ event on every field of the form to the server whether this field is correct or not, creating a new model or finding the row if it contains an id.

This way you don’t need to replicate logic in your client that is already defined and implemented in your model at the server.

You can read more about realtime-validations here. You can also find the project on github.

  • Feddgs

    Hi, First of all thank you very much for this great gem!

    I have just a little problem, im using twitter-bootstrap in my application, and for_form for forms to users create an account. The gems works great, but the only problem is the error/ok message showing under the form, and i try everithing to show the error/ok message at the left of the form.

    I customize the errors/ok style in this way:


    RealtimeValidations.showErrors = function(field, errors) {
    field.parent().append('' + '' + ' '
    + errors.join(', ') +
    '');
    $('#' + field.attr('id') + '_error').fadeIn('slow');
    }

    RealtimeValidations.hideErrors = function(field) {
    if ($('#' + field.attr('id') + '_error').length) {
    $('#' + field.attr('id') + '_error').fadeOut('slow', function() {
    $(this).remove();
    RealtimeValidations.showValidSmoothly(field);
    });
    } else if ($('#' + field.attr('id') + '_valid').length) {
    return;
    } else {
    RealtimeValidations.showValidSmoothly(field);
    }
    }

    RealtimeValidations.showValid = function(field) {
    field.parent().append(' \
    Seems Ok! \
    ');
    $('#' + field.attr('id') + '_valid').fadeIn('slow');
    }

    RealtimeValidations.hideValid = function(field) {
    $('#' + field.attr('id') + '_valid').length)
    }

    Do you have an idea how can i show the messages at left of the forms fields?

    Thanks again for the gem!

  • You might want to consider h5Validate, isetnad. It does live validation according to well researched best-practices has endured arduous testing by its corporate sponsors in preparation to launch to millions of users, works virtually everywhere (including mobile), everything is configurable, and development is very active.Oh yeah and it uses the html5 standards for form validation, but works on browsers as old as IE6.