aboutsummaryrefslogtreecommitdiffstats
path: root/js/validate_hero.js
blob: 6d29a53f97a300b18d0ce19d371f82f2c6d73e2f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
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;

}