script.js 742 B

12345678910111213141516171819202122
  1. $('#exo1-form').submit(function(e) {
  2. e.preventDefault();
  3. var form = $(this);
  4. var inputPass = form.find('input[type="password"]');
  5. var mdp = inputPass.val();
  6. if(mdp.length < 6) {
  7. $('#mdp-statut')
  8. .show()
  9. .addClass('text-red')
  10. .html('Mot de passe trop court (6 caractères minimum)');
  11. }
  12. var inputName = form.find('input[name="nom"]');
  13. var nom = inputName.val();
  14. if(! nom || (nom.split(' ').length < 2)) {
  15. $('#nom-statut')
  16. .show()
  17. .addClass('text-red')
  18. .html('Le nom doit être rempli et comporter un espace');
  19. }
  20. $('#result').html("Bienvenue " + inputName.val() +
  21. ", votre mot de passe contient " + mdp.length + " caractères");
  22. });