2
I do a very rough check to see if the form is filled in, in case it is not appearing a alert("Preencha todos os campos!");
, the problem is that when I click OK it reloads the page and thus cleaning the form.
- I need the Alert OK button not to clear the form.
- If possible I want you to mark in red the fields that are not filled in.
JS
$('#btnCadMed').click(function(){
var nome = $("#txtNome").val();
var CRM = $("#txtCRM").val();
var idt = $("#txtIdentificador").val();
var esp = $("#txtEspecialidade").val();
if(nome == "" || CRM == "" || idt == "" || esp == ""){
alert("Preencha todos os campos!");
}else{
$("#txtNome").val("");
$("#txtCRM").val("");
$("#txtIdentificador").val("");
$("#txtEspecialidade").val("");
alert("Médico cadastrado com sucesso!");
}
});
Print by Alert
Already tried to use a false Return ??
– Lucas Caresia