0
Honestly, it’s been 3 days that I’m trying to validate an input, the business theoretically seems simple, but in practice is not validating anything.
The situation is as follows:
This is a part of my index.html
<script>
function checkForm(form) {
// validation fails if the input is blank
if (form.name.value == null || form.name.value == '' || form.name.value == "") {
alert("Existe Algum Campo Vazio (Isso Não Pode Acontecer)");
form.name.focus();
return false;
}
return true;
} </script>
Here comes my head followed by form
<form onsubmit="return checkForm(this);">
<div>
Name: <input type="text" ng-model="aviso.nome" required name="name"
value="" aria-describedby="name-format" />
</div>
<input type="submit" ng-click="SalvarAvisos()" />
<input type="button" value="limparCampo" ng-click="limparCampo()" />
</form>
I lay all, looking like this seems to me that there has to be some validation in the
ng-click="Save warnings()"
but I am lost, because even though the field is empty or null, the error message appears, but the form is sent in the same way, I know that it is sent pq in the database appears there "null".
Obg for getting to the end. Bomdia&boaspesquisas
If you are using Angularjs why not validate the elements by your models applied through $context?
– Guilherme Nascimento
I’ll search this $context , there’s a lot of front stuff, I’m picking up this full pace yet.
– Anderson Galindro