Created
November 20, 2014 22:48
-
-
Save MattWilliamsDev/50e552009618316d4dfe to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| var init = function() { | |
| /* $( "input[name=a1]" ).change(function() { | |
| $("#b1").val(0); | |
| $("#c1").val(0); | |
| sumItUp(); | |
| }); | |
| $( "input[name=b1]" ).change(function() { | |
| $("#a1").val(0); | |
| $("#c1").val(0); | |
| sumItUp(); | |
| }); | |
| $( "input[name=c1]" ).change(function() { | |
| $("#a1").val(0); | |
| $("#b1").val(0); | |
| sumItUp(); | |
| }); */ | |
| var $ar4ec = $("#ar4ec").validate({ | |
| // Rules for form validation | |
| rules : { | |
| exemption : { | |
| required : true | |
| }, | |
| a1 : { | |
| required : true, | |
| digits : true, | |
| max: 9 | |
| }, | |
| b1 : { | |
| required : true, | |
| digits : true, | |
| max: 9 | |
| }, | |
| c1 : { | |
| required : true, | |
| digits : true, | |
| max: 9 | |
| }, | |
| two : { | |
| required : true, | |
| digits : true, | |
| max: 9 | |
| }, | |
| three : { | |
| required : true, | |
| digits : true, | |
| max: 9 | |
| }, | |
| four : { | |
| required : true, | |
| digits : true, | |
| max: 99999 | |
| }, | |
| five : { | |
| required : true | |
| }, | |
| status : { | |
| required : true | |
| }, | |
| signature : { | |
| required : true | |
| }, | |
| date : { | |
| required : true | |
| } | |
| }, | |
| // Messages for form validation | |
| messages : { | |
| radio : { | |
| required : 'Select one please.' | |
| }, | |
| a1 : { | |
| required : 'Fill out or put zero please.', | |
| digits : 'Digits only please.' | |
| }, | |
| b1 : { | |
| required : 'Fill out or put zero please.', | |
| digits : 'Digits only please.' | |
| }, | |
| c1 : { | |
| required : 'Fill out or put zero please.', | |
| digits : 'Digits only please.' | |
| }, | |
| two : { | |
| required : 'Fill out or put zero please.', | |
| digits : 'Digets only please.' | |
| }, | |
| three : { | |
| required : 'Fill out or put zero please.', | |
| digits : 'Digits only please' | |
| }, | |
| four : { | |
| required : 'Fill out or put zero please.' | |
| }, | |
| five : { | |
| required : 'Please Select one.' | |
| }, | |
| status : { | |
| required : 'Please select one.' | |
| }, | |
| signature : { | |
| required : 'Fill out name' | |
| }, | |
| date : { | |
| required : 'Can not be blank' | |
| } | |
| }, | |
| // Ajax form submition | |
| submitHandler : function(form) { | |
| $(form).ajaxSubmit({ | |
| success : function() { | |
| // validation worked here so get the form by elements | |
| var tiid = getParameterByName('tiid'); | |
| var formData = getFormData(); | |
| formData = JSON.stringify( formData ); | |
| console.log(formData); | |
| $.post('/ajxep/_putFormData.php', {tiid:tiid,data:formData}, function(data, textStatus, xhr) { | |
| /*optional stuff to do after success */ | |
| }); | |
| } | |
| }); | |
| }, | |
| // Do not change code below | |
| errorPlacement : function(error, element) { | |
| error.insertAfter(element.parent()); | |
| console.log(error); | |
| } | |
| }); | |
| $( "input[name=two]" ).change(function() { | |
| sumItUp(); | |
| }); | |
| $( "input[name=three]" ).change(function() { | |
| sumItUp(); | |
| }); | |
| $('#date').datepicker({ | |
| dateFormat : 'yy-mm-dd', | |
| prevText : '<i class="fa fa-chevron-left"></i>', | |
| nextText : '<i class="fa fa-chevron-right"></i>', | |
| maxDate : 0, | |
| minDate : -30 | |
| }); | |
| // radio on change event so we know what to put in the fields | |
| $('input[name=exemption]').change(function() { | |
| if ( $(this).val() === "a") { | |
| // correct the stuff. | |
| $( this ).val( 1 ); | |
| } else if ( $(this).val() === "b") { | |
| $( this ).val( 2 ); | |
| } else if ( $(this).val() === "c") { | |
| $( this ).val( 2 ); | |
| } | |
| sumItUp(); | |
| }); | |
| }; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment