Subversion Repositories SmartDukaan

Rev

Go to most recent revision | Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
7226 anupam.sin 1
$(function() {
2
	$('#pincodeForm').submit(function() {
3
 
4
		if($('#pincodeSubmit:hidden').length == 1) {
5
			return false;
6
		}
7
 
8
		if ($('#pincodeText').val().length != 6) {
9
			alert('Please enter 6 digit pin code');
10
			return false;
11
		}
12
 
13
		var result = $('#pincodeText').val().match(/^\d*$/);
14
		if(result == null || result.length == 0) {
15
			alert('Please enter a valid pin code');
16
			return false;
17
		}
18
 
19
		showLoading();
20
		$.ajax({
21
			type: "POST",
22
			url: "/storewebsite/order-details!getPricingDetails",
23
			dataType:"json",
24
			timeout: 3000,
25
			success:function(msg) {
26
				hideLoading();
27
				if(msg.length != 0) {
28
					$('#priceDiv').html(
29
					"<div class='date'><span class='infoText'>Get this product by </span><span class='infoValue'>" + msg.displayDate + "</span></div>" + 
30
					"<div class='price'><span class='infoText'>Total Price</span><span class='infoValue'>&nbsp;Rs.&nbsp;" + msg.price + "</span></div>" +
31
					"</div><div class='advance'><span class='infoText'>Advance to be paid</span><span class='infoValue'>&nbsp;Rs.&nbsp;" + msg.advanceAmount + "</span></div>");
32
					$('#pincodeInput').val($('#pincodeText').val());
33
				} else {
34
					$('#priceDiv').html("<div class='error'>No info found for this pincode. Please try again.</div>");
35
				}
36
			},
37
			error : function(msg) {
38
				$('#loading').hide();
39
				$('#shippingAddress').hide();
40
				$('#priceDiv').html("<div class='error'>There was some error. Please try again.</div>");
41
				$('#pincodeSubmit').show();
42
	        },
43
	        complete : function() {
44
	        	$('#pinSpan').html($('#pincodeText').val());
45
 
46
	        }
47
		});
48
		return false;
49
	});
50
 
51
	function showLoading() {
52
		$('#pincodeSubmit').hide();
53
		$('#shippingAddress').hide();
54
		$('#loading').show();
55
	}
56
 
57
	function hideLoading() {
58
		$('#loading').hide();
59
		$('#shippingAddress').show();
60
	}
61
 
62
	$('#changePincode').click(function() {
63
		$('#shippingAddress')[0].reset();
64
		$('#shippingAddress input:hidden').val('');
65
		$('#shippingAddress').hide();
66
		$('#priceDiv').empty();
67
		$('#pincodeSubmit').show();
68
	});
69
});
70
 
71
function validateAddress() {
72
	if ($('input[name=line1]').val() == "") {
73
		alert('Please enter a shipping address');
74
		return false;
75
	}
76
	if ($('input[name=line2]').val() == "") {
77
		alert('Please enter a shipping address');
78
		return false;
79
	}
80
	if ($('input[name=city]').val() == "") {
81
		alert('Please enter the name of the city');
82
		return false;
83
	}
84
	if ($('input[name=state]').val() == "") {
85
		alert('Please enter the name of the state');
86
		return false;
87
	}
88
	return true;
89
}