Jump to content

[SOLVED] Form validation Function


liquinas

Recommended Posts

Hi all!

 

I have this function which checks for empty fields that have class="required" on a form before submitting. What I want to know is if I can use more than one qualifying flag. For example both class="required" and class="peanut" but not anything else.

 

function validate() {
var result = $('.required').map(function (index, domElement) {
	var flag = "true";
	if ($(this).val().length < 1) {
		$(this).css({backgroundColor:"red"});
		flag = "false";
	} else {
		$(this).css({backgroundColor:"white"});
	}
	return flag;
});
return result;
}

 

:-* Thanks in advance for any advice

Link to comment
https://forums.phpfreaks.com/topic/120776-solved-form-validation-function/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.