﻿function setError(msg, divId) {
    //$(divId).html(msg);
    alert(msg);
}

function cleanError(divId) {
    $(divId).empty();
}

function IsValid(tipo) {
    var ok = true;

    $("input[tipo='" + tipo + "']").each(function() {
        if ($(this).attr("req") == "true") {
            if (this.value == $(this).attr("title") || this.value.length == 0) {
                ok = false;
            }
        }
    });

    if (ok == true) {
        $("input[tipo='" + tipo + "']").each(function() {
            if (this.value == $(this).attr("title"))
                this.value = "";
        });
    }
    return ok;
}

function IsMailValid(el) {    
    if (!validateMail(el.val())) {
        return false;
    }
    return true;
}

function validateMail(src) {
    var emailReg = "^[\\w-_\.+]*[\\w-_\.]\@([\\w]+\\.)+[\\w]+[\\w]$";
    var regex = new RegExp(emailReg);
    return regex.test(src);
}
