blpraveen
(Blpraveen2004)
1
Hi,
My Search form looks like this
$form= ActiveForm::begin(['id'=>'search-form','validationUrl'=> Url::to('home/SearchValidate'),
'validateOnSubmit'=> true,'action'=>'result','enableAjaxValidation'=>true,
'options' => ['data-pjax' => true ]);
<?php ActiveForm::end(); ?>
$script ="
function my_validate_custom_function() {
}
";
$this->registerJs($script, View::POS_END);
How do I add my custom validation to the yiiActiveForm?
After search validation it generates a key to be used in the url.
How to specify the redirect url on validation success?
blpraveen
(Blpraveen2004)
2
Hi,
I don’t know if this is right. But I am getting result what I wanted
var validate_url = '".Url::to(['home/searchvalidate'])."';
jQuery('#search-form').on('submit', function(e) {
//Custom validation
var extData = '&ajax=' + jQuery(this).prop('id');
var \$button = jQuery(this).find(':submit:first');
if (\$button && \$button.length && \$button.prop('name')) {
extData += '&' + \$button.prop('name') + '=' + \$button.prop('value');
}
jQuery.ajax( {
url: validate_url,
type: 'POST',
dataType: 'json',
data: jQuery(this).serialize() + extData,
success: function (data, status)
{
},
error: function (xhr, desc, err)
{
}
});
});