Template:2011FR/Form-section-radiobuttons: Difference between revisions
Jump to navigation
Jump to search
Content deleted Content added
fixed typo |
No edit summary |
||
Line 82: | Line 82: | ||
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, |
|||
'AED' : 4, |
|||
'ARS' : 4, |
|||
'AUD' : 1, |
|||
'BBD' : 2, |
|||
'BDT' : 76, |
|||
'BGN' : 1.4, |
|||
'BHD' : 0.4, |
|||
'BMD' : 1, |
|||
'BND' : 1.3, |
|||
'BOB' : 7, |
|||
'BRL' : 1.7, |
|||
'BSD' : 1, |
|||
'BZD' : 2, |
|||
'CAD' : 1, |
|||
'CHF' : 0.9, |
|||
'CLP' : 494, |
|||
'CNY' : 6, |
|||
'COP' : 1910, |
|||
'CRC' : 512, |
|||
'CZK' : 18, |
|||
'DKK' : 5, |
|||
'DOP' : 38, |
|||
'DZD' : 73, |
|||
'EEK' : 11, |
|||
'EGP' : 6, |
|||
'EUR' : 0.7, |
|||
'GBP' : 0.6, |
|||
'GTQ' : 7.8, |
|||
'HKD' : 7.7, |
|||
'HNL' : 19, |
|||
'HRK' : 5, |
|||
'HUF' : 219, |
|||
'IDR' : 8960, |
|||
'ILS' : 3.6, |
|||
'INR' : 49, |
|||
'JMD' : 85, |
|||
'JOD' : 0.7, |
|||
'JPY' : 78, |
|||
'KES' : 97, |
|||
'KRW' : 1127, |
|||
'KYD' : 0.8, |
|||
'KZT' : 147, |
|||
'LBP' : 1500, |
|||
'LKR' : 110, |
|||
'LTL' : 2.5, |
|||
'LVL' : 0.5, |
|||
'MAD' : 8.1, |
|||
'MKD' : 45, |
|||
'MUR' : 29, |
|||
'MVR' : 15, |
|||
'MXN' : 13, |
|||
'MYR' : 3, |
|||
'NOK' : 5.5, |
|||
'NZD' : 2, |
|||
'OMR' : 4, |
|||
'PAB' : 1, |
|||
'PEN' : 4, |
|||
'PHP' : 43, |
|||
'PKR' : 86, |
|||
'PLN' : 3, |
|||
'PYG' : 4190, |
|||
'QAR' : 4, |
|||
'RON' : 4, |
|||
'RUB' : 30, |
|||
'SAR' : 4, |
|||
'SEK' : 7, |
|||
'SGD' : 1.2, |
|||
'SVC' : 9, |
|||
'THB' : 30, |
|||
'TJS' : 4.7, |
|||
'TND' : 2, |
|||
'TRY' : 2, |
|||
'TTD' : 6, |
|||
'TWD' : 30, |
|||
'UAH' : 8, |
|||
'UYU' : 19, |
|||
'UZS' : 1760, |
|||
'VND' : 21000, |
|||
'XAF' : 470, |
|||
'XCD' : 2.7, |
|||
'XOF' : 476, |
|||
'ZAR' : 7.8 |
|||
}; |
|||
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 22:40, 13 November 2011