I'm wondering if could be a better way for:

PHP Code:
var $parentDiv element.parent();
                var 
currentClass $parentDiv.attr('class');
                
element.on('blur',function() {
                    
$parentDiv.removeClass();
                    
$parentDiv.addClass(currentClass);
                    if(
ctrl.$valid){
                        
$parentDiv.addClass('has-success');
                     }
                     else{
                        
$parentDiv.addClass('has-error'); 
                     }
                }); 
think of element such as
Code:
$('#myid')
if the input is valid
Code:
ctrl.$valid