Blame | Last modification | View Log | RSS feed
$(function(){$('#dth-image').click(function(){trackEventWithGA('Recharge', 'Recharge Type', 'DTH');$('#serviceType').val('2');$('#serviceSelectForm').submit();});$('#phone-image').click(function(){trackEventWithGA('Recharge', 'Recharge Type', 'Mobile');$('#serviceType').val('1');$('#serviceSelectForm').submit();});jQuery('#planDropDown').change(function() {jQuery('#planDescription').html(jQuery('#planDropDown option:selected').attr('desc'));});jQuery('.showDenomination').live("click", function() {var denominationType = jQuery(this).attr('denominationType');var operatorId = jQuery('#operatorSelector option:selected').val();var circleCode = jQuery('#circleCode').val();jQuery('#popularPlansInner').empty();$('#popularPlansInner').append('<div style="padding-top:90px;" align="center" class="img"><img title="loading" alt="loading" src="/images/loading.gif"></div>');jQuery('#popularPlansDiv').show();jQuery.ajax({type : "GET",url : "/recharge!getAllDenominations?operatorId=" + operatorId + "&circleCode=" + circleCode + "&denominationType=" + denominationType,success : function(response) {jQuery('#popularPlansInner').empty();jQuery('#popularPlansInner').html(response);},error : function() {jQuery('#popularPlansInner').empty();jQuery('#popularPlansInner').html("<div style='padding:15px;'>This information is unavailable for now.<br>You can recharge with the amount you normally use or you can try later.</div>");}});});jQuery('.populateAmount').live("click", function() {jQuery('#amountInput').val(jQuery(this).text());jQuery('#popularPlansDiv').hide();});jQuery('#closePlans').click(function() {jQuery('#popularPlansDiv').hide();});$.validator.addMethod("rangeamount", function(value,element){return value >= 10 && value <= 1000;}, "Recharge amount should be between Rs. 10-1000");$.validator.addMethod("rangeamount1", function(value,element){return value >= 200 && value <= 2000;}, "Recharge amount should be between Rs. 200-2000");$.validator.addMethod("dishtv", function(value,element){if (jQuery('#operatorSelector').val()!=1){return true;} else {return value >= 250 && value <= 2000;}}, "Recharge amount should be between Rs. 250-2000");$.validator.addMethod("selectoperator", function(value,element){return $(element).find("option:selected").index()!=0;}, "Please select operator");$('#atmSelection').validate({rules:{name:{required:true},line1:{required:true},state:{required:true},city:{required:true},pincode:{required:true,digits:true},phone:{required:true,minlength:10,digits:true},},messages:{name:{required:"Please enter the name"},line1:{required:"Please enter the address"},state:{required: "Please select a state"},city:{required: "Please enter the city"},pincode:{required: "Please enter the pincode",digits:"Please enter a valid pincode"},phone:{required: "Please enter the phone number",digits:"Please enter a valid number",minlength:"Number should be of 10 digits"}}});$('#ccSelection').validate({rules:{name:{required:true},line1:{required:true},state:{required:true},city:{required:true},pincode:{required:true,digits:true},phone:{required:true,minlength:10,digits:true},},messages:{name:{required:"Please enter the name"},line1:{required:"Please enter the address"},state:{required: "Please select a state"},city:{required: "Please enter the city"},pincode:{required: "Please enter the pincode",digits:"Please enter a valid pincode"},phone:{required: "Please enter the phone number",digits:"Please enter a valid number",minlength:"Number should be of 10 digits"}}});$('#bankSelection').validate({rules:{name:{required:true},line1:{required:true},state:{required:true},city:{required:true},pincode:{required:true,digits:true},phone:{required:true,minlength:10,digits:true},},messages:{name:{required:"Please enter the name"},line1:{required:"Please enter the address"},state:{required: "Please select a state"},city:{required: "Please enter the city"},pincode:{required: "Please enter the pincode",digits:"Please enter a valid pincode"},phone:{required: "Please enter the phone number",digits:"Please enter a valid number",minlength:"Number should be of 10 digits"}}});rechargeFormValidator = $('#rechargeDetailsForm').validate({rules:{number:{required:true,minlength:10,digits:true},dthnumber:{required:true},amount:{required:true,digits:true,rangeamount:true},dthamount:{required:true,digits:true,dishtv:true,rangeamount1:true},email:{required:true,email:true},operator:{selectoperator:true}},messages:{number:{required:"Please enter the mobile number",digits:"Please enter a valid number",minlength:"Number should be of 10 digits"},dthnumber:{required:"Please enter the DTH number"},amount:{required: "Please enter amount",digits: "Recharge amount should be between Rs. 10-1000",rangeamount:"Recharge amount should be between Rs. 10-1000"},dthamount:{required: "Please enter amount",digits: "Recharge amount should be between Rs. 200-2000"},operator:{selectoperator:"Please select operator"}}});oldValue = "";$('#rechargeDetailsForm input[name="number"]').unbind('keyup blur').bind('keyup blur', function(){var numvalue = $(this).val().substring(0,4);var count = $(this).val().length;if(count==10 && oldValue != numvalue){getRechargeProvider(numvalue, 1);oldValue = numvalue;//$(this).unbind('keyup');}});function getRechargeProvider(deviceNumber, rechargeType){return $.ajax({type: "POST",url: "/recharge!getServiceProvider?deviceNumber=" + deviceNumber + "&serviceType=" + rechargeType,success:function(msg){if(msg != ""){var deviceNumberInfo = msg.split(":");$('#rechargeDetailsForm select[name="operator"]').val($.trim(deviceNumberInfo[0]));$('#circleCode').val($.trim(deviceNumberInfo[1]));$('#operatorSelector').trigger('change');}}});}jQuery('#applyRechargeCoupon').click(function() {var code = $.trim($('#discountCode').val());if ( code == '') {alert('No coupon applied');} else {$('#discountCode').val(code);jQuery('#create-recharge-form').attr('action', '/confirm!applyRechargeCoupon');jQuery('#create-recharge-form').submit();}});jQuery('#recharge-pay-now-button').click(function() {jQuery('#create-recharge-form').attr('action', '/confirm!createRecharge');jQuery('#create-recharge-form').submit();});jQuery('#recharge-now-button').click(function() {jQuery('#recharge-now-button').hide();var formName = "create-recharge-form";var captcha_response_input = jQuery("form[name='" + formName + "'] :input[name='captcha_response_field']");var entered_text = jQuery.trim(captcha_response_input.val());if(entered_text == '' || entered_text == 'Enter the characters shown'){dispError("Please enter the characters shown.");captcha_response_input.blur();jQuery('#recharge-now-button').show();return;}jQuery('#create-recharge-form').attr('action', '/confirm!createRecharge');jQuery('#captcha-div').append('<span id=\'recharge-loading\' style="display:inline-block;width:200px;height: 30px;background: url(\'/images/loading.gif\') no-repeat 8px 0;padding-left: 45px;padding-top: 7px;">Please Wait ...</span>');jQuery('#create-recharge-form').submit();});function dispError(msg) {alert(msg);}jQuery('#captchaanchor').click(function () { jQuery('#captchaImage').attr('src', '/captcha?rand=' + Math.floor(Math.random()*100) ); });jQuery('#captcha_response_box').val('Enter the characters shown').focus(function(){if ($(this).val() == 'Enter the characters shown') {$(this).val('');$(this).removeClass('captcha_text_blur');$(this).addClass('captcha_text_focus');}}).blur(function(){if ($(this).val() == '') {$(this).val('Enter the characters shown');$(this).removeClass('captcha_text_focus');$(this).addClass('captcha_text_blur');}});});