Validetta demos

Back to examples

Using callback functions

onValid() and onError()


To show error messages healthy, each field must be wrapped by an element like <div>

<div id="alert"></div>
<form id="exm" method="POST" action="#">
        <label>Required, Email :</label>
        <input type="text" name="name" data-validetta="required,minLength[2],maxLength[3]">
        <label>Email :</label>
        <input type="text" name="email" data-validetta="required,email">
    <button type="submit">Submit</button>
    <button type="reset">Reset</button>
        onValid : function( event ) {
                .append('<div class="alert alert-success">Nice, Form is valid</div>');
        onError : function( event ){
                .append('<div class="alert alert-danger">Stop bro !! There are some errors.</div>');