custom validation does not seem to get registered.
- by viet pham
Hi,
Inside a tab, I have a form that is dynamically loaded via ajax. Since the name of the field is dynamic too (e.g. ), I write a custom validation method inside the "on complete" like this. However, the custom code does not get executed (bolded alert never pops up) no matter what i try.
$.ajax
(
{
url: 'index.php?func=trainingmgr&aAction=displayAddForm',
type: 'GET',
dataType: 'html',
complete: function(req, err)
{
//Append response to the tab's body
$(href, '#trainingTabs').append(req.responseText);
$.validator.addMethod
(
'tRequired',
function(value, element)
{
if(value == '')
{ **alert('I am empty');** return true; }
else return false;
},
'<br>Required field'
);
$('#upload' + index).click
(
function()
{ $('#addForm' + index).validate().numberOfInvalids(); }
);
}
}
);