added status messages to the email submission form

pull/4/head
joates 10 years ago
parent b2696fe0eb
commit f620653e86

@ -12,6 +12,8 @@
margin-left: -5px; margin-left: -5px;
} }
.input{width: 100%;} .input{width: 100%;}
#status-msg.info{color: black}
#status-msg.error{color: red}
/*mq madness*/ /*mq madness*/
.maxW, .dskW,.tblW{display:none;} .maxW, .dskW,.tblW{display:none;}
@ -28,4 +30,4 @@
@media (max-width: 979px) { @media (max-width: 979px) {
.tblW{display:block;} .tblW{display:block;}
} }
@media (min-width: 980px) {} @media (min-width: 980px) {}

@ -34,6 +34,7 @@
<input type="checkbox" name="paris"> Paris Nov.2014? <input type="checkbox" name="paris"> Paris Nov.2014?
</label> </label>
<button type="submit" class="btn">Send</button> <button type="submit" class="btn">Send</button>
<div id="status-msg">&nbsp;</div>
</fieldset> </fieldset>
</form> </form>
</div> </div>

@ -6,6 +6,7 @@ process.nextTick(function() {
var form = document.getElementById('signup-form') var form = document.getElementById('signup-form')
, input_email = '' , input_email = ''
, status_msg = document.getElementById('status-msg')
for (var n = 0, l = form.childNodes[1].childNodes.length; n < l; n++) { for (var n = 0, l = form.childNodes[1].childNodes.length; n < l; n++) {
var el = form.childNodes[1].childNodes[n] var el = form.childNodes[1].childNodes[n]
@ -20,11 +21,16 @@ process.nextTick(function() {
if (input_email && input_email.value) { if (input_email && input_email.value) {
var is_valid = check_email(input_email.value) var is_valid = check_email(input_email.value)
if (is_valid) { if (is_valid) {
alert('got it, thanks '+ input_email.value) status_msg.className = 'info'
form.submit() status_msg.innerHTML = "Got it, thanks"
setTimeout(function() { form.submit() }, 600)
} else { } else {
input_email.value = '' input_email.value = ''
alert("that doesn't look like an email address,\nplease try again...") e.preventDefault()
status_msg.className = 'error'
status_msg.innerHTML = "that doesn't look like an email address,"
+ "<br />please try again..."
setTimeout(function() { status_msg.innerHTML = '&nbsp;' }, 2000)
} }
} }
} }

Loading…
Cancel
Save