diff --git a/.project b/.project new file mode 100644 index 0000000..01c386b --- /dev/null +++ b/.project @@ -0,0 +1,11 @@ + + + white_fedtest + + + + + + + + diff --git a/index.html b/index.html index ad0297d..f37bb60 100644 --- a/index.html +++ b/index.html @@ -11,23 +11,29 @@

Lorem ipsum dolor sit amet, consectetur adipiscing elit.

-
+

Nibh Hendrerit Sodales

-
+ diff --git a/js/main.js b/js/main.js new file mode 100644 index 0000000..bd6a4e0 --- /dev/null +++ b/js/main.js @@ -0,0 +1,91 @@ +// jsonp call +function update_form (data) { +var edu = document.getElementById("education"); + for(var key in data){ + if (key !== 'some') { + var attrName = key; + var attrValue = data[key]; + var label = document.createElement("label"); + radioInput = document.createElement('input'); + radioInput.setAttribute('type', 'radio'); + radioInput.setAttribute('name', 'edu'); + radioInput.setAttribute('value', attrName); + label.insertAdjacentHTML('afterBegin', attrValue); + label.appendChild(radioInput); + edu.appendChild(label); + } + } +}; + +window.onload=function(){ + var script_element = document.createElement('script'); + script_element.src = 'http://fedtest.aws.af.cm/?callback=update_form'; + document.getElementsByTagName('head')[0].appendChild(script_element); +}; + +// End jsonp call + + +// form validation +var err = 0; +function validate(e){ + var val = document.getElementById(e).value; + switch (e) + { + case "fname": + if(!val){err = 0; }else{ err = 1; } + checkError(e); + break; + case "lname": + if(!val){err = 0; }else{ err = 1; } + checkError(e); + break; + case "phone": + var phoneno = /^\(?([0-9]{3})\)?[-. ]?([0-9]{3})[-. ]?([0-9]{4})$/; + if(!val.match(phoneno)){err = 0; }else{ err = 1; } + checkError(e); + break; + case "email": + var email = /^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/; + if(!val.match(email)){err = 0; }else{ err = 1; } + checkError(e); + break; + } +}; + +function checkError(e){ + var error = document.getElementById(e+'Error'); + var errorClass = error.className; + if(errorClass == "validate" && err == 0){ + error.className = errorClass + " error"; + } + else if(errorClass == "validate error" && err >= 1){ + error.className = errorClass = ""; + error.className = errorClass + "validate"; + } +} + +function lastCheck(){ + var radio = document.getElementsByName('edu'); + var isradio; + for (var i=0; i input, .error > div{ + border: 1px solid #FF0000 !important; +} + +.error:before { + content: attr(title); + position: absolute; + right: 20px; + color: #FF0000; + font-size: 9px; +} + + .actions button { width: 100%; padding: 10px; @@ -75,3 +101,23 @@ input { padding-left: 20px; } +@media only screen +and (max-width : 960px) { + + .container { width: 100%;} + .container img{width: 100%;} + form{margin-top: -29%;} + .content { width: 50%;} +} + +@media only screen +and (max-width : 480px) { + + body{min-width: 320px; min-height: 480px;} + h1{ font-size: 14pt; } + form{float: none; margin: -29% auto; width: 250px;} + .content {width: 90%; padding: 30% 10px; margin: 0 auto;} + .content p{width: 100%;} +} + +