aboutsummaryrefslogtreecommitdiffstats
path: root/js/validate_hero.js
diff options
context:
space:
mode:
authoralexvitkov <44268717+alexvitkov@users.noreply.github.com>2021-01-29 12:52:06 +0200
committerGitHub <noreply@github.com>2021-01-29 12:52:06 +0200
commit33e533d28dbf9ad7bfc7ad9af467e5efe25ae8a0 (patch)
tree7b748d2b87ab018d7ff451b4111a1b88eeb58416 /js/validate_hero.js
parentceedd596c9f39f53555fd0746a42d6b85cd49b6c (diff)
parent472e170f408e3d8d1db2eb066d445153aad55d73 (diff)
downloadfileup-33e533d28dbf9ad7bfc7ad9af467e5efe25ae8a0.tar.gz
Merge pull request #1 from GTSimeonov/master
rararrararararraar
Diffstat (limited to 'js/validate_hero.js')
-rw-r--r--js/validate_hero.js58
1 files changed, 58 insertions, 0 deletions
diff --git a/js/validate_hero.js b/js/validate_hero.js
new file mode 100644
index 0000000..6d29a53
--- /dev/null
+++ b/js/validate_hero.js
@@ -0,0 +1,58 @@
+
+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_login_form()
+{
+ var username=document.forms["hero_form"]["username"].value;
+ var flag=true;
+ clear_hero_errors();
+
+ if(username.length==0)
+ {
+ document.getElementById("username-length-error").hidden=false;
+ flag=false;
+ }
+ document.activeElement.blur();
+ return flag;
+}
+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.length==0)
+ {
+ document.getElementById("password-length-error").hidden=false;
+ flag=false;
+ }
+ if(password !== password2)
+ {
+ document.getElementById("password-match-error").hidden=false;
+ flag=false;
+ }
+ document.activeElement.blur();
+ return flag;
+
+}