-
Notifications
You must be signed in to change notification settings - Fork 0
/
kontaktJs.js
57 lines (49 loc) · 1.18 KB
/
kontaktJs.js
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
function prijava(){
var ime = document.getElementById('txtName');
var email=document.getElementById('txtEmail');
var reIme = /^[a-z]{1,14}\s[a-z]{1,19}$/;
var reEmail=/^[A-z0-9]{3,}@[A-z]{3,}$/;
var greske = new Array();
var greskeID = new Array();
var sadrzaj = new Array();
if(!ime.value.match(reIme))
{
greske.push("Ime i prezime nisu u dobrom formatu!");
greskeID.push(ime.id);
}
else
{
sadrzaj.push(ime.value);
}
if(!email.value.match(reEmail))
{
greske.push("Email nije u dobrom formatu!");
greskeID.push(email.id);
}
else
{
sadrzaj.push(email.value);
}
if(greske.length == 0)
{
var tekst = "<ul>";
for(var i = 0; i < sadrzaj.length; i++)
{
tekst += "<li>" + sadrzaj[i] + "</li>";
}
tekst += "</ul>";
document.getElementById('ispis').innerHTML = tekst;
}
else
{
for(var i = 0; i < greskeID.length; i++)
{
document.getElementById(greskeID[i]).style.border="1px solid red";
}
var listaGresaka = "";
for(var i = 0; i < greske.length; i++)
{
listaGresaka += greske[i] + "<br />";
}
document.getElementById('ispis').innerHTML = listaGresaka;
}}