r102833 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r102832‎ | r102833 | r102834 >
Date:00:48, 12 November 2011
Author:kaldari
Status:ok
Tags:
Comment:
making form validation smarter - only check for empty values if form input actually exists
Modified paths:
  • /trunk/extensions/DonationInterface/modules/validate_input.js (modified) (history)
  • /trunk/extensions/DonationInterface/payflowpro_gateway/form_placeholders.js (modified) (history)

Diff [purge]

Index: trunk/extensions/DonationInterface/payflowpro_gateway/form_placeholders.js
@@ -20,9 +20,11 @@
2121 currField = '';
2222
2323 for( i = 0; i < numFields; i++ ) {
24 - if( document.getElementById( fields[i] ).value == '' ) {
25 - currField = mw.msg( 'donate_interface-error-msg-' + fields[i] );
26 - output += mw.msg( 'donate_interface-error-msg-js' ) + ' ' + currField + '.\r\n';
 24+ if ( document.getElementById( fields[i] ) ) { // Make sure field exists
 25+ if( document.getElementById( fields[i] ).value == '' ) {
 26+ currField = mw.msg( 'donate_interface-error-msg-' + fields[i] );
 27+ output += mw.msg( 'donate_interface-error-msg-js' ) + ' ' + currField + '.\r\n';
 28+ }
2729 }
2830 }
2931
Index: trunk/extensions/DonationInterface/modules/validate_input.js
@@ -55,10 +55,12 @@
5656 var fields = ['fname','lname','street','city','zip', 'emailAdd'],
5757 numFields = fields.length;
5858 for( i = 0; i < numFields; i++ ) {
59 - // See if the field is empty or equal to the placeholder
60 - if( document.getElementById( fields[i] ).value == '' || document.getElementById( fields[i] ).value == mw.msg( 'donate_interface-donor-'+fields[i] ) ) {
61 - currField = mw.msg( 'donate_interface-error-msg-' + fields[i] );
62 - output += mw.msg( 'donate_interface-error-msg-js' ) + ' ' + currField + '.\r\n';
 59+ if ( document.getElementById( fields[i] ) ) { // Make sure field exists
 60+ // See if the field is empty or equal to the placeholder
 61+ if( document.getElementById( fields[i] ).value == '' || document.getElementById( fields[i] ).value == mw.msg( 'donate_interface-donor-'+fields[i] ) ) {
 62+ currField = mw.msg( 'donate_interface-error-msg-' + fields[i] );
 63+ output += mw.msg( 'donate_interface-error-msg-js' ) + ' ' + currField + '.\r\n';
 64+ }
6365 }
6466 }
6567
@@ -118,10 +120,12 @@
119121 var fields = ['fname','lname','street','city','zip', 'emailAdd', 'card_num','cvv'],
120122 numFields = fields.length;
121123 for( i = 0; i < numFields; i++ ) {
122 - // See if the field is empty or equal to the placeholder
123 - if( document.getElementById( fields[i] ).value == '' || document.getElementById( fields[i] ).value == mw.msg( 'donate_interface-donor-'+fields[i] ) ) {
124 - currField = mw.msg( 'donate_interface-error-msg-' + fields[i] );
125 - output += mw.msg( 'donate_interface-error-msg-js' ) + ' ' + currField + '.\r\n';
 124+ if ( document.getElementById( fields[i] ) ) { // Make sure field exists
 125+ // See if the field is empty or equal to the placeholder
 126+ if( document.getElementById( fields[i] ).value == '' || document.getElementById( fields[i] ).value == mw.msg( 'donate_interface-donor-'+fields[i] ) ) {
 127+ currField = mw.msg( 'donate_interface-error-msg-' + fields[i] );
 128+ output += mw.msg( 'donate_interface-error-msg-js' ) + ' ' + currField + '.\r\n';
 129+ }
126130 }
127131 }
128132

Follow-up revisions

RevisionCommit summaryAuthorDate
r102842MFT r102576, r102577, r102579, r102581, r102804, r102805, r102812, r102819, r...awjrichards02:20, 12 November 2011
r102929Re-attempting MFT r102576, r102577, r102578, r102579, r102581, r102689, r1027...khorn00:50, 14 November 2011

Status & tagging log