Add validation to yiiActiveForm.js

How do I add this code into yiiactiveform.js to prevent conflict?


$("#w0").on("submit", function () {

		if ($("#theid").val().length === 0 && $("#theid2").val().length === 0) {

			$(".field-name .help-block").text("error message");

			$(".field-name").removeClass("has-success").addClass("required has-error");

			$(".field-name2 .help-block").text("error message");

			$(".field-name2").removeClass("has-success").addClass("required has-error");

			return false;

		} else {

			$(".field-name .help-block").text("");

			$(".field-name").removeClass("required has-error").addClass("has-success");

			$(".field-name2 .help-block").text("");

			$(".field-name2").removeClass("required has-error").addClass("has-success");

			return true;

		}

	});

Describe the conflict details

Or you can put that code into view file where use ActiveForm

I originally thought it was a conflict, it is now working, but I was hoping to make it cleaner by implementing it using activeform instead of a separate validation code on my end, I didn’t know how to start, but I was looking here: http://yii2-cookbook.readthedocs.org/forms-activeform-js/

Usually vendor files do not touch, and own code is added over the vendor scripts