I’m tired of this jquery.yiiactiveform.jс in yii 1.1.9 nothing works correctly.
-
if i use ajax validation the captcha does’t work
-
if i use client validation without validateOnSubmit and just submit the form, then when the fields are entered correcty the error css is not removed from the control, just error message disappears.
-
if i use client validation and validateOnSubmit then jquery multifile upload does’t work and i need to click several times on submit button to submit the form.
Can you please give me working scenario, how to use client validation?
this is the form:
-
jquery multifile upload
-
text input
-
captcha
-
submit button
‘enableClientValidation’=>true,
‘validateOnSubmit’=>false,
///edit
so after debugging i have found the error if validateOnSubmit is false,
when server site validation is performed and the "error" css is set to the control, but when client site validation is made after that, the "error" css is removed ONLY from the container
quick fix: please make it better
$.fn.yiiactiveform.updateInput = function (attribute, messages, form) {
attribute.status = 1;
var $error, $container,
hasError = false,
$el = form.find('#' + attribute.inputID);
if($el.length) {
hasError = messages !== null && $.isArray(messages[attribute.id]) && messages[attribute.id].length > 0;
$error = form.find('#' + attribute.errorID);
$container = $.fn.yiiactiveform.getInputContainer(attribute, form);
$container.removeClass(
attribute.validatingCssClass + ' ' +
attribute.errorCssClass + ' ' +
attribute.successCssClass
);
form.find('#' + attribute.inputID).removeClass(
attribute.validatingCssClass + ' ' +
attribute.errorCssClass + ' ' +
attribute.successCssClass
);
if (hasError) {
$error.html(messages[attribute.id][0]);
$container.addClass(attribute.errorCssClass);
}
else if (attribute.enableAjaxValidation || attribute.clientValidation) {
$container.addClass(attribute.successCssClass);
}
if (!attribute.hideErrorMessage) {
$error.toggle(hasError);
}
attribute.value = getAFValue($el);
}
return hasError;
};