diff options
author | adam <adam@> | 2021-01-29 02:16:01 +0200 |
---|---|---|
committer | adam <adam@> | 2021-01-29 02:16:01 +0200 |
commit | 5d3d901d968db7eb3da9c038e6d823f7c75f1e10 (patch) | |
tree | fca4e9228f79895adde5b1f0686f864abbe5d045 /js/validate_hero.js | |
parent | 758afd5feefbf3a76f5c6abe8bff8c08f39dd7cc (diff) | |
download | fileup-5d3d901d968db7eb3da9c038e6d823f7c75f1e10.tar.gz |
some cosmetic stuff
Diffstat (limited to 'js/validate_hero.js')
-rw-r--r-- | js/validate_hero.js | 43 |
1 files changed, 43 insertions, 0 deletions
diff --git a/js/validate_hero.js b/js/validate_hero.js new file mode 100644 index 0000000..118abbf --- /dev/null +++ b/js/validate_hero.js @@ -0,0 +1,43 @@ + +function clear_hero_errors() +{ + var errors = document.getElementsByClassName("hero_form_error"); + var i; + for (i = 0; i < errors.length; i++) + { + errors[i].hidden = true; + } +} +function validate_hero_form() +{ + var username=document.forms["hero_form"]["username"].value; + var email=document.forms["hero_form"]["email"].value; + var password=document.forms["hero_form"]["password"].value; + var password2=document.forms["hero_form"]["password2"].value; + + var flag=true; + clear_hero_errors(); + + if(username.length==0) + { + document.getElementById("username-length-error").hidden=false; + flag=false; + } + if(!email.match(/\S+@\S+/)) + { + document.getElementById("email-error").hidden=false; + flag=false; + } + if(password !== password2) + { + document.getElementById("password-error").hidden=false; + flag=false; + } + + if(flag) + { + document.getElementById("success").hidden=false; + } + return flag; + +} |