Link to home
Start Free TrialLog in
Avatar of Panos
PanosFlag for Germany

asked on

Jquery validation by class

Hello experts.
I need help to validate a form in a modal window by classname using jquery validation plugin.
My form is  id="formcategories"
My required textfields : class="categoryclass"

If one of the textfields doesn't pass the validation - add to this class error (like i would handle this with id validation)
Attached my code
var editcategory = function(id){
    var p = $("#popuploader");
    p.dialog({
        autoOpen: false,
        width: 300,
        height: 300
    });
    p.dialog({
       buttons: {
            "Save": function () {
                var targetUrl = "index.cfm";
                var b = $("#formcategories");
                var a = b.valid();
                if (a) {
                    var f = b.serialize();
                    $.post("actions/actupdate.cfm", f, function (g) {
                        if (g) {
                            
							window.location.href = targetUrl;
                           
                        }
                    })
                }
            
            },
            "Cancel": function () {
                $(this).dialog("close");
                $(this).dialog("destroy");
            }
        }
    });
	p.dialog("open");
	p.load("forms/frmtext.cfm?categoryid=" + id, function (c, e, d) {
            if (e == "success") {
			 $("#formcategories").validate({
				 
				 }
			   )
	
            } else {
                alert("errorload")
            }
        });
};

Open in new window


Any help?
ASKER CERTIFIED SOLUTION
Avatar of designatedinitializer
designatedinitializer
Flag of Portugal image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Panos

ASKER

Hi designatedinitializer
where do i have to place this code inside my script so that the form will be validated on:
var a = b.valid();
Avatar of Panos

ASKER

Finally i got it.
Thank you for your help
Avatar of Panos

ASKER

thank you
regards
panos