Template:2011FR/Form-section-radiobuttons: Difference between revisions
Jump to navigation
Jump to search
Content deleted Content added
No edit summary |
moving pieces around |
||
Line 45: | Line 45: | ||
document.getElementById("input_amount_other_box").value = "</html>{{int:donate_interface-other}}<html>"; |
document.getElementById("input_amount_other_box").value = "</html>{{int:donate_interface-other}}<html>"; |
||
document.getElementById("input_amount_other_box").style.color = "#aaaaaa"; |
document.getElementById("input_amount_other_box").style.color = "#aaaaaa"; |
||
} |
|||
function validateForm(form){ |
|||
var minimums = { |
|||
'USD' : 1, |
|||
'GBP' : 1, // $1.26 |
|||
'EUR' : 1, // $1.26 |
|||
'AUD' : 2, // $1.35 |
|||
'CAD' : 1, // $0.84 |
|||
'CHF' : 1, // $0.85 |
|||
'CZK' : 20, // $1.03 |
|||
'DKK' : 5, // $0.85 |
|||
'HKD' : 10, // $1.29 |
|||
'HUF' : 200, // $0.97 |
|||
'JPY' : 100, // $1 |
|||
'NZD' : 2, // $1.18 |
|||
'NOK' : 10, // $1.44 |
|||
'PLN' : 5, // $1.78 |
|||
'SGD' : 2, // $1.35 |
|||
'SEK' : 10, // $1.28 |
|||
'ILS' : 5 // $1.39 |
|||
}; |
|||
var error = true; |
|||
// Get amount selection |
|||
for ( var i = 0; i < form.amount.length; i++ ) { |
|||
if ( form.amount[i].checked ) { |
|||
amount = form.amount[i].value; |
|||
} |
|||
} |
|||
if ( form.input_amount_other_box.value != "</html>{{int:donate_interface-other}}<html>" ) { |
|||
var otherAmount = form.input_amount_other_box.value; |
|||
otherAmount = otherAmount.replace(/[,.](\d)$/, '\:$10'); |
|||
otherAmount = otherAmount.replace(/[,.](\d)(\d)$/, '\:$1$2'); |
|||
otherAmount = otherAmount.replace(/[\$,.]/g, ''); |
|||
otherAmount = otherAmount.replace(/:/, '.'); |
|||
form.input_amount_other_box.value = otherAmount; |
|||
form.amountGiven.value = otherAmount; |
|||
amount = otherAmount; |
|||
} |
|||
// Check amount is a real number |
|||
error = ( amount == null || isNaN( amount ) || amount.value <= 0 ); |
|||
// Check amount is at least the minimum |
|||
var currency = form.currency_code.value; |
|||
if ( typeof( minimums[currency] ) == 'undefined' ) { |
|||
minimums[currency] = 1; |
|||
} |
|||
if ( amount < minimums[currency] || error ) { |
|||
alert( '</html>{{{validation-error-minimum|You must contribute at least $1}}}<html>'.replace('$1', minimums[currency] + ' ' + currency ) ); |
|||
error = true; |
|||
} |
|||
return !error; |
|||
} |
} |
||
Revision as of 16:10, 5 November 2011