Index: trunk/extensions/SemanticFormsInputs/SemanticFormsInputs.i18n.php |
— | — | @@ -15,6 +15,7 @@ |
16 | 16 | 'semanticformsinputs-dateformatlong' => 'd MM yy', // see http://docs.jquery.com/UI/Datepicker/formatDate |
17 | 17 | 'semanticformsinputs-dateformatshort' => 'dd/mm/yy', // see http://docs.jquery.com/UI/Datepicker/formatDate |
18 | 18 | 'semanticformsinputs-firstdayofweek' => '0', // 0 - sunday, 1 - monday... |
| 19 | + 'semanticformsinputs-malformedregexp' => 'Malformed regular expression ($1).', |
19 | 20 | |
20 | 21 | 'semanticformsinputs-datepicker-dateformat' => 'The date format string. See the [http://www.mediawiki.org/w/index.php?title=Extension:Semantic_Forms_Inputs&fromsection=Date_picker#Parameters online documentation] for more information.', |
21 | 22 | 'semanticformsinputs-datepicker-weekstart' => 'The first day of the week (0 - Sunday, 1 - Monday, ...).', |
— | — | @@ -63,6 +64,7 @@ |
64 | 65 | |
65 | 66 | {{doc-important|This is an ''optional'' message. Do not translate it, if it would remain unchanged in your language. }}", |
66 | 67 | 'semanticformsinputs-firstdayofweek' => '0 - sunday, 1 - monday...', |
| 68 | + 'semanticformsinputs-malformedregexp' => 'An error message.', |
67 | 69 | |
68 | 70 | 'semanticformsinputs-datepicker-dateformat' => 'This is a help text for the Special:CreateForm page.', |
69 | 71 | 'semanticformsinputs-datepicker-weekstart' => 'This is a help text for the Special:CreateForm page.', |
Index: trunk/extensions/SemanticFormsInputs/libs/regexp.js |
— | — | @@ -18,13 +18,21 @@ |
19 | 19 | */ |
20 | 20 | function SFI_RE_validate ( input_id, params ) { //input_number, retext, inverse, message, multiple |
21 | 21 | |
22 | | - var re = new RegExp( jQuery( "<div/>" ).html( params.retext ).text() ); |
23 | | - var match = re.test( jQuery('#' + input_id).attr("value") ); |
| 22 | + var match; |
| 23 | + var message; |
| 24 | + try { |
| 25 | + var re = new RegExp( jQuery( "<div/>" ).html( params.retext ).text() ); |
| 26 | + match = re.test( jQuery('#' + input_id).attr("value") ); |
| 27 | + message = params.message; |
| 28 | + } catch (e) { |
| 29 | + match = false; |
| 30 | + message = params.error.replace('$1', e ); |
| 31 | + } |
24 | 32 | |
25 | 33 | if ( ( match && ! params.inverse ) || ( ! match && params.inverse ) ) { |
26 | 34 | return true; |
27 | 35 | } else { |
28 | | - jQuery( '#' + input_id ).parent().addErrorMessage(params.message); |
| 36 | + jQuery( '#' + input_id ).parent().addErrorMessage( message ); |
29 | 37 | return false; |
30 | 38 | } |
31 | 39 | } |