mardi 13 septembre 2016

Difference between if else validation methods

Is there a pro or con to doing simple validation one way or another? What is the best practice? When would you use one over the other?

first method:

if ( <validate> ){
  submitForm();
} else {
  alert('Error');
    exitFn();
}

second method:

if ( !<validate> ){
  alert('Error!');
    exitFn();
}

submitForm();

Aucun commentaire:

Enregistrer un commentaire