Why doesn’t the form validate the fields?

Asked

Viewed 55 times

0

I am making a validation of the registration screen so that it is reusable to the registration change screen, when it is registration is properly establishing, but when it is the change it does not take

/**
	 * Funcao para verificar se é para alterar funcionario a partir da persisitnecia do id
	 */
	$scope.enableChangePassword = function() {
		console.log("verificando se é para alterar funcionario");
		list  = document.getElementsByClassName("iptPass");
		if ($scope.meuUsuario.getId() != '') {
			document.getElementById("checkbox").style.display="block";
			document.getElementById("PassBox").className += "col-md-12";	
			for (index = 0; index < list.length; ++index) {
				list[index].style.display="none";
			}
			console.log($scope.meuUsuario.getId() != '');  
		}else {
			document.getElementById("checkbox").style.display="none";
			for (index = 0; index < list.length; ++index) {
				list[index].setAttribute("required","");
			}
		}
	}
	
	$scope.init = function (){
		$scope.enableChangePassword();
	}
	
	$scope.init();
<div class="tabs-container" ng-controller="GetMoreUserController">
<div ng-include="cadUsuariosTab.url"></div>
<div ng-init="tab=2">
<div class="wizard-container" ng-init="quad=1">
    <div class="card wizard-card ct-wizard-red">
    <br>
        <ul class="nav nav-pills" role="tablist">
            <li role="">
                <a aria-controls="Dados do Titulo" role="tab" data-toggle="tab" ng-click="quad=1" ng-class="{'active' : quad==1}">
                    Dados Básicos
                </a>
            </li>
            <li role="">
                <a aria-controls="Pesquisa" role="tab" data-toggle="tab" aria-label="Toggle" ng-click="quad=2" ng-class="{'active' : quad==2}">
                    Dados Complementares
                </a>
            </li>
        </ul>
    </div>
    <div class="tabs-container" ng-controller="CadUserController">
    	<br>
        <form id="formCadUser" ng-init="carregarUsuarioAlteracao()" name="formCadUser" class="col-md-8" ng-submit="">
            <div class="tab-content" ng-show="quad == 1">

                <div class="col-md-6 form-group">
                    <label for="nome">Nome</label>
                    <input id="nome" name="nome" type="text" class="form-control" ng-model="caduser.nome" ng-minlength="2" required>
                </div>
                <div class="col-md-6 form-group">
                    <label for="sobrenome">Sobrenome</label>
                    <input name="sobrenome" type="text" class="form-control" ng-model="caduser.sobrenome" ng-minlength="2" required>
                </div>
                <div class="col-md-12 form-group">
                    <label for="username">Username</label>
                    <input id="login" name="username" type="text" class="form-control" ng-model="caduser.login" ng-minlength="2" required>
                </div>
                <div class="col-md-12 form-group">
                    <label for="email">Email</label>
                    <input name="email" type="email" class="form-control" ng-model="caduser.email" ng-minlength="6" required>
                </div>
                <div id="PassBox">
               		<div id="checkbox"><label><input id="cb" type="checkbox"> Alterar Senha</label></div>
	                <div class="col-md-6 form-group iptPass">
	                    <label for="senha">Senha</label>
	                    <input name="senha" type="password" class="form-control" ng-change="clearAlert()" ng-model="caduser.senha" ng-minlength="4" >
	                </div>
	                <div class="col-md-6 form-group iptPass">
	                    <label for="senha">Confirme a Senha</label>
	                    <input name="confSenha" type="password" class="form-control" ng-change="clearAlert()"  ng-model="caduser.confSenha" ng-minlength="4" >
	                </div>
				</div>
				
            </div>
            <div class="tab-content" ng-show="quad == 2">
                <div class="col-md-6 form-group">
                    <label for="senha">Campo Qualquer</label>
                    <input name="" type="text" class="form-control">
                </div>
            </div>

            <div class="container-fluid form-group">
                <div class="col-md-4 pull-right">
                    <br/>
                    <div>
                        <!--<button type="submit" name="submit" class="btn btn-default pull-right col-md-6" ng-click="cadastrarUsuario()" ng-disabled="formCadUser.$invalid"> -->
                        <button type="submit" name="submit" class="btn btn-default pull-right col-md-6"  ng-click="cadastrarUsuario()" ng-disabled="formCadUser.$invalid">
                            Cadastrar
                            <span class="glyphicon glyphicon-ok-circle"></span>
                        </button>
                        <button type="reset" value="" name="clear" class="btn btn-default pull-left col-md-5" >
                            Limpar
                            <span class="glyphicon glyphicon-remove-circle"></span>
                        </button> 
                    </div>
                </div>
            </div>
            <div id="alerta"></div>
            <hr>
        </form>
    </div>
    </div>
   </div>
</div>

1 answer

1


According to the HTML code you have placed, there is no method call init() or enableChangePassword() nowhere on the page (in Scope).

  • init it happens with the loading of the controller it is inserted

Browser other questions tagged

You are not signed in. Login or sign up in order to post.