-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathshatner.js
42 lines (34 loc) · 1.28 KB
/
shatner.js
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
jQuery(function($){
$('.cart').click(function(){
// Test to see if the price exceeds the minimum price (ie the Suggested Price):
if($('#minimum_price').length && parseFloat($('#minimum_price').val()) > parseFloat($('input.name_price').val()))
{
alert('Please offer a price higher than the Minimum Price.');
return false;
}
// See if the price input is zero (because we want people to be able to choose a free option: NEEDS LOGIC FOR SET MINIMUM
else if(parseFloat($('input.name_price').val()) == 0)
{
return;
}
// Test to see if the input field has been left blank:
else if($('.name_price').length && !parseFloat($('input.name_price').val()))
{
alert('Please enter a price in the Price field!');
return false;
}
// Test to see if input field is non-negative:
else if(parseFloat($('input.name_price').val()) < 0)
{
alert("Look here, old chap, that's just not on. Please enter a positive number, or zero. Tsk tsk.");
return false;
}
});
$('.cart').submit(function(){
if ($(this).children('input[name="price"]').length == 0)
{
$('<input name="price" />').val($('input.name_price').val()).attr('type','hidden').appendTo($('form.cart'));
}
return;
});
});