diff --git a/js/import.js b/js/import.js
index e97af14c49..5b00f44bf6 100644
--- a/js/import.js
+++ b/js/import.js
@@ -57,6 +57,57 @@ AJAX.registerTeardown('import.js', function () {
});
AJAX.registerOnload('import.js', function () {
+ // import_file_form validation.
+ $('#import_file_form').live('submit', function (event) {
+ var radioLocalImport = $("#radio_local_import_file");
+ var radioImport = $("#radio_import_file");
+ var fileMsg = '

' + PMA_messages.strImportDialogMessage + '
';
+
+ if (radioLocalImport.length !== 0) {
+ // remote upload.
+ // TODO Remove this section when all browsers support HTML5 "required" property
+ if (! radioLocalImport.is(":checked") && ! radioImport.is(":checked")) {
+ radioImport.focus();
+ var msg = '
';
+ msg += PMA_messages.strRadioUnchecked;
+ msg += '
';
+ PMA_ajaxShowMessage(msg, false);
+ return false;
+ }
+
+ if (radioImport.is(":checked") && $("#input_import_file").val() === '') {
+ $("#input_import_file").focus();
+ PMA_ajaxShowMessage(fileMsg, false);
+ return false;
+ }
+
+ if (radioLocalImport.is(":checked")) {
+ if ($("#select_local_import_file").length === 0) {
+ PMA_ajaxShowMessage('
' + PMA_messages.strNoImportFile + '
', false);
+ return false;
+ }
+
+ if ($("#select_local_import_file").val() === '') {
+ $("#select_local_import_file").focus();
+ PMA_ajaxShowMessage(fileMsg, false);
+ return false;
+ }
+ }
+ } else {
+ // local upload.
+ if ($("#input_import_file").val() === '') {
+ $("#input_import_file").focus();
+ PMA_ajaxShowMessage(fileMsg, false);
+ return false;
+ }
+ }
+
+ // show progress bar.
+ $("#upload_form_status").css("display", "inline");
+ $("#upload_form_status_info").css("display", "inline");
+ return;
+ });
+
// Initially display the options for the selected plugin
changePluginOpts();
diff --git a/js/messages.php b/js/messages.php
index 502a64abf9..d210c56e85 100644
--- a/js/messages.php
+++ b/js/messages.php
@@ -46,6 +46,7 @@ $js_messages['strConfirmDeleteQBESearch'] = __('Do you really want to delete the
/* For indexes */
$js_messages['strFormEmpty'] = __('Missing value in the form!');
+$js_messages['strRadioUnchecked'] = __('Select at least one of the options!');
$js_messages['strEnterValidNumber'] = __('Please enter a valid number!');
$js_messages['strEnterValidLength'] = __('Please enter a valid length!');
$js_messages['strAddIndex'] = __('Add Index');
@@ -201,6 +202,7 @@ $js_messages['strFailedBuildingGrid'] = __('Failed building chart grid with impo
$js_messages['strImport'] = __('Import');
$js_messages['strImportDialogTitle'] = __('Import monitor configuration');
$js_messages['strImportDialogMessage'] = __('Please select the file you want to import.');
+$js_messages['strNoImportFile'] = __('No files available on server for import!');
$js_messages['strAnalyzeQuery'] = __('Analyse Query');
diff --git a/libraries/display_import.lib.php b/libraries/display_import.lib.php
index c4d71f6100..97e9afd1f9 100644
--- a/libraries/display_import.lib.php
+++ b/libraries/display_import.lib.php
@@ -58,9 +58,6 @@ function PMA_getHtmlForImportJS($upload_id)
$html .= ' $("#buttonGo").bind("click", function() {';
// hide form
$html .= ' $("#upload_form_form").css("display", "none");';
- // show progress bar
- $html .= ' $("#upload_form_status").css("display", "inline");';
- $html .= ' $("#upload_form_status_info").css("display", "inline");';
if ($_SESSION[$SESSION_KEY]["handler"] != "UploadNoplugin") {
@@ -230,7 +227,7 @@ function PMA_getHtmlForImportOptionsFile($max_upload_size, $import_list)
$html .= '