1
0
mirror of https://github.com/fspc/Yellow-Bike-Database.git synced 2025-02-22 17:03:22 -05:00

Adds error validation for email list slider.

This commit is contained in:
Jonathan Rosenbaum 2015-02-12 18:47:25 +00:00
parent 763587f840
commit 55a8de3df8
3 changed files with 31 additions and 14 deletions

View File

@ -153,8 +153,10 @@ $totalRows_Recordset1 = mysql_num_rows($Recordset1);
<tr> <tr>
<td><label>Email List:</label></td> <td><label>Email List:</label></td>
<td> <td>
<div id="email_list_block">
<div id="email_list_toggle" style="width: 50px;"></div> <div id="email_list_toggle" style="width: 50px;"></div>
<span id="email_list_error"></span> <div id="email_list_error"></div>
</div>
</td> </td>
</tr> </tr>
<tr > <tr >

View File

@ -1,7 +1,7 @@
/* errors */ /* errors */
#waiver_error, #phone_error, #email_error, #waiver_error, #phone_error, #email_error,
#first_name_error, #last_name_error #first_name_error, #last_name_error, #email_list_error
{ {
color: red; color: red;
} }
@ -18,8 +18,9 @@
border-color: green; border-color: green;
} }
/* get rid of the pesky handle stripping with specificity */
#email_list_toggle > div > div > div.hello:before, #email_list_toggle > div > div > div.hello:after, /* get rid of the pesky handle stripping with specificity (when figured out) */
#email_list_toggle > div > div > div:before, #email_list_toggle > div > div > div:after,
{ {
content: none; content: none;
} }
@ -41,5 +42,10 @@
right: -32px; right: -32px;
} }
#email_list_block > div {
display: inline-block;
}
/* end email list toggle */

View File

@ -21,7 +21,8 @@ $(function(){
zip.mask('00000-0000', {placeholder: "00000-0000"}); zip.mask('00000-0000', {placeholder: "00000-0000"});
state_abbreviation.mask('AA',{placeholder: "WV", translation: {"A": {pattern: /[A-Za-z]/, recursive: false} } }); state_abbreviation.mask('AA',{placeholder: "WV", translation: {"A": {pattern: /[A-Za-z]/, recursive: false} } });
// spiff up contact pull down // spiff up contact pull down
var email_list_choice;
$("select[name='contact_id']").chosen(); $("select[name='contact_id']").chosen();
$("#submit_contact").on("click keypress", function(e) { $("#submit_contact").on("click keypress", function(e) {
@ -30,6 +31,9 @@ $(function(){
//error_handler(input,error_span,error,error_text,event); //error_handler(input,error_span,error,error_text,event);
var err0 = 0, err1 = 0; var err0 = 0, err1 = 0;
// if it is showing
$("#email_list_error").hide();
// first name & last name input // first name & last name input
error_handler(first_name.val(), first_name_error, "","*Required",e); error_handler(first_name.val(), first_name_error, "","*Required",e);
@ -46,10 +50,14 @@ $(function(){
email_error.hide(); email_error.hide();
phone_error.hide(); phone_error.hide();
var r = phone_validator(phone.val(),e); var r = phone_validator(phone.val(),e);
var email_list_toggle = $("#email_list_toggle");
var email_list_error = $("#email_list_error");
if (r) { if (r) {
if($("#email_list_toggle").val() == 1) { if(email_list_toggle.val() == 1) {
console.log("here i am s" + r); error_handler(1, email_list_error, 1,"*Email address required for email list",e);
} email_list_choice = 1;
}
} }
} else if ( (email.val() !== "" && phone.val() === "") ) { } else if ( (email.val() !== "" && phone.val() === "") ) {
@ -88,8 +96,14 @@ $(function(){
c--; c--;
} }
});
}); // end submit_contact
$("#email_list_toggle").on("set",function() {
if ($(this).val() == 0 && email_list_choice) {
$("#email_list_error").hide();
}
} );
function phone_validator(val, e) { function phone_validator(val, e) {
var re = /^\(\d{3}\)\s?\d{3}-\d{4}$/; var re = /^\(\d{3}\)\s?\d{3}-\d{4}$/;
@ -153,11 +167,6 @@ $(function(){
$("#email_list_toggle").addClass('toggle'); $("#email_list_toggle").addClass('toggle');
$("#email_list_toggle").addClass('noUi-extended'); $("#email_list_toggle").addClass('noUi-extended');
$("#email_list_toggle > div > div > div").addClass("hello");
$('.noUi-handle').hover(function(){
$(this).attr('data-content','none');
});
$("#email_list_toggle").Link('lower').to(toggle); $("#email_list_toggle").Link('lower').to(toggle);