script.js 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. function chek(){
  2. var fName = document.getElementById("fName").value;
  3. var lName = document.getElementById('lName').value;
  4. var email = document.getElementById("email").value.toLowerCase();
  5. var password = document.getElementById('password').value;
  6. var error = document.getElementById("error");
  7. if(password==""){
  8. document.getElementById('password').style.border="1.5px solid red"
  9. }else {
  10. document.getElementById('password').style.border="1.5px solid #94b0a4"
  11. };
  12. if(email==""){
  13. document.getElementById("email").style.border="1.5px solid red"
  14. }else {
  15. document.getElementById("email").style.border="1.5px solid #94b0a4"
  16. }
  17. if(fName==""){
  18. document.getElementById("fName").style.border="1.5px solid red"
  19. }else {
  20. document.getElementById("fName").style.border="1.5px solid #94b0a4"
  21. };
  22. if(lName==""){
  23. document.getElementById('lName').style.border="1.5px solid red"
  24. }else{
  25. document.getElementById('lName').style.border="1.5px solid #94b0a4"
  26. };
  27. if(fName.indexOf(" ") != -1){
  28. error.innerHTML = "enter first name without space";
  29. error.style.color="red";
  30. }else if(lName.indexOf(" ") != -1){
  31. error.innerHTML = "enter last name without space";
  32. error.style.color="red";
  33. }else if(password.length <= 6){
  34. error.innerHTML = "password must be longer than 6 characters";
  35. error.style.color="red";
  36. }else if(email.slice(-10) != "@gmail.com"){
  37. error.innerHTML = "Enter your email with the domain gmail.com";
  38. error.style.color="red";
  39. }else{
  40. error.innerHTML ='Sing Up for Free';
  41. error.style.color="#fff";
  42. alert("вы успешно зарегестрировались")
  43. };
  44. }