Hi.
I'm taking my first steps with Jquery.
To practice with it I tried to develope this simple
validator system:
PHP Code:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<
html>
<
head>
<
title>Test</title>
<
meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<
script type="text/javascript" src="jquery/jquery-1.2.2.js"></script>
<script type="text/javascript">
function isEmpty(val) {
   return !/\S/.test(val);

function isValidEmail(str) {
    // http://www.devpro.it/php4_id_2.html
    return Boolean(str.match(/^([a-z0-9]+[\._\-]?){1,3}([a-z0-9])*\@([a-z0-9]+[\.\-]?){1,3}([a-z0-9])*\.[a-z]{2,6}$/i));
};
function isEmptyV(id,errMsg){
    this.el= $(id);
    this.isValid= function(){
        var isValid= true;
        if(isEmpty($(id).val())){
            this.error= errMsg;
            isValid= false;
        }
        return isValid;
    }
};
function isValidEmailV(id,errMsg){
    this.el= $(id);
    this.isValid= function(){
        var isValid= true;
        if(!isValidEmail($(id).val())){
            this.error= errMsg;
            isValid= false;
        }
        return isValid;
    }
};
function Validator() {
     var validators= [];
    this.errors= [];
    this.values= {};
    this.add= function(objV){
        validators.push(objV);
    }
    this.isValid= function(){
        var isValidFlag= true;
        for(var i=0, len= validators.length;i< len;i++){
            if(!validators[i].isValid()){
                this.errors.push({error:validators[i].error,el:validators[i].el});
                isValidFlag= false;
            }
            else{
                this.values[$(validators[i].el).attr('id')]=$(validators[i].el).val();
            }
        }
        return isValidFlag;
    }
}
function checkForm(){
    var errMsgName= 'Invalid name';
    var errMsgSurname= 'Invalid surname';
    var errMsgEmail= 'Invalid email';
    var validator = new Validator();
    validator.add(new isEmptyV('#c-name',errMsgName));
    validator.add(new isEmptyV('#c-surname',errMsgSurname));
    validator.add(new isEmptyV('#c-email',errMsgEmail));
    if(!validator.isValid()){
        alert(validator.errors[0].error);
        // do something ie set input border style
        $(validator.errors[0].el).css({ border: "1px solid #EE0000"});
            return false;
        }    
        alert(validator.values['c-email']);
        //do something ie send  validator.values with Json
        
}
$(document).ready( function () {
    $('#frm').submit(
        function(){
            return checkForm();
        }
    );
});
</script>
</head>
<body>
<form action="" method="post" id="frm">
<p><input type="text" name="c_name"  value="" maxlength="50" tabindex="1" id="c-name"  /></p>
<p><input type="text" name="c_surname"  value="" maxlength="50" tabindex="2" id="c-surname"  /></p>
<p><input type="text" name="c_email"  value="" maxlength="50" tabindex="4" id="c-email"  /></p>
<p><input type="submit" name="c_send" value="Send &raquo;" tabindex="5" id="news-submit"  /></p>
</form>
</body>
</html> 
I realize it's a mix-up of Jquery and 'old way'
could you help me to realize a better script ?

I didn't find anything about sending json data
with Jquery is there a way without using the standard
json library ?

Bye.