-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcommon.js
More file actions
172 lines (158 loc) · 5.55 KB
/
common.js
File metadata and controls
172 lines (158 loc) · 5.55 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
$(document).ready(function(){
$("#sub_deals option[value='Commercial']").hide();
//Loading Progress Start
$("#myDiv").hide();
$("#loading-image").hide();
//Loading Progress End
$(".onlyNumbers").keypress(function (e) {
if (e.which != 8 && e.which != 0 && (e.which < 48 || e.which > 57)) {
return false;
}
});
$('#clear_btn').on('click', function(){
$('#mortgage_form')[0].reset();
$('.sourcePreviewXml').html('');
$(".sourcexml_values").show()
$('.mortgage_values'). hide();
});
$('.mortgage_values'). hide();
$('#previewXml').on('click', function(){
if($(".mortgage_values").is(":visible")){
$(".sourcexml_values").show()
$('.mortgage_values'). hide();
}
});
$('#mortgage_type').on('change', function(){
$("#sub_deals").prop("disabled",false);
$('#sub_deals').get(0).selectedIndex = 0;
$('input[name="type"]').val('Residential');
$('input[name="purpose"]').val('Purchase');
$("#repayment__").prop("checked",true);
if(($(this).val() == 'first_time_buyer') || ($(this).val() == 'moving_home')){
$("#sub_deals option[value='Commercial']").hide();
$("#sub_deals option[value!='Commercial']").show();
}else if($(this).val() == 'buy_to_let'){
$("#interest-only__").prop("checked",true);
$('input[name="type"]').val('buy-to-let');
$("#sub_deals option[value!='Commercial']").hide();
$("#sub_deals option[value='Commercial']").show();
}else if($(this).val() == 'remortgage'){
$('input[name="purpose"]').val('Remortgage');
$("#sub_deals").prop("disabled",true);
}
});
$('#calculate_btn').on('click', function(){
var delay = 2000;
$("#myDiv").show();
$("#loading-image").show();
//Condition to check if the mortage amount greater than property value
var property_value = $('#property_value').val();
var mortgage_amount = $('#mortgage_amount').val();
var mortgage_terms = $('#terms').val();
var deals_fixed = $.trim($("input[name='deals_fixed']:checked"). val());
var deals_variable = $.trim($("input[name='deals_variable']:checked"). val());
if(property_value == ''){
alert('Enter the Property Value');
$('#property_value').focus();
$("#myDiv").hide();
$("#loading-image").hide();
return false;
}else if(mortgage_amount == ''){
alert('Enter the Mortgage Amount');
$('#mortgage_amount').focus();
$("#myDiv").hide();
$("#loading-image").hide();
return false;
}else if(parseInt(mortgage_amount) > parseInt(property_value)){
alert('Mortgage Amount should be less than Property Value');
$('#mortgage_amount').focus();
$("#myDiv").hide();
$("#loading-image").hide();
return false;
}else if(mortgage_terms == ''){
alert('Enter the Mortgage Terms');
$('#terms').focus();
$("#myDiv").hide();
$("#loading-image").hide();
return false;
}else if((deals_fixed == '') && (deals_variable == '')) {
alert("Please Choose any option in 'Type of Mortgage'");
$('#deals_fixed').focus();
$("#myDiv").hide();
$("#loading-image").hide();
return false;
}
$.ajax({
type:'POST',
url: 'preview_xml.php',
data: $('#mortgage_form').serialize(),
headers: {'X-CSRF-Token': $('meta[name="csrf-token"]').attr('content')},
success:function(data){
$("#myDiv").hide();
$("#loading-image").hide();
$('.sourcePreviewXml').html(data);
if($(".mortgage_values").is(":visible")){
$(".sourcexml_values").show()
$('.mortgage_values'). hide();
}
}
})
});
$('#resultsDiv').on('click', function(){
var delay = 2000;
$("#myDiv").show();
$("#loading-image").show();
//Condition to check if the mortage amount greater than property value
var property_value = $('#property_value').val();
var mortgage_amount = $('#mortgage_amount').val();
var mortgage_terms = $('#terms').val();
var deals_fixed = $.trim($("input[name='deals_fixed']:checked"). val());
var deals_variable = $.trim($("input[name='deals_variable']:checked"). val());
if(property_value == ''){
alert('Enter the Property Value');
$('#property_value').focus();
$("#myDiv").hide();
$("#loading-image").hide();
return false;
}else if(mortgage_amount == ''){
alert('Enter the Mortgage Amount');
$('#mortgage_amount').focus();
$("#myDiv").hide();
$("#loading-image").hide();
return false;
}else if(parseInt(mortgage_amount) > parseInt(property_value)){
alert('Mortgage Amount should be less than Property Value');
$('#mortgage_amount').focus();
$("#myDiv").hide();
$("#loading-image").hide();
return false;
}else if(mortgage_terms == ''){
alert('Enter the Mortgage Terms');
$('#terms').focus();
$("#myDiv").hide();
$("#loading-image").hide();
return false;
}else if((deals_fixed == '') && (deals_variable == '')) {
alert("Please Choose any option in 'Type of Mortgage'");
$('#deals_fixed').focus();
$("#myDiv").hide();
$("#loading-image").hide();
return false;
}
$.ajax({
type:'POST',
url: 'calculate.php',
data: $('#mortgage_form').serialize(),
headers: {'X-CSRF-Token': $('meta[name="csrf-token"]').attr('content')},
success:function(data){
$("#myDiv").hide();
$("#loading-image").hide();
$('.mortgage_values').html(data);
if($(".sourcexml_values").is(":visible")){
$('.mortgage_values'). show();
$(".sourcexml_values").hide()
}
}
})
});
});