Index: modules/shortcut/shortcut.admin.inc
===================================================================
RCS file: /cvs/drupal/drupal/modules/shortcut/shortcut.admin.inc,v
retrieving revision 1.13
diff -u -p -r1.13 shortcut.admin.inc
--- modules/shortcut/shortcut.admin.inc	24 Apr 2010 14:49:14 -0000	1.13
+++ modules/shortcut/shortcut.admin.inc	21 May 2010 17:52:03 -0000
@@ -102,6 +102,22 @@ function shortcut_set_switch($form, &$fo
 }
 
 /**
+ * Validation handler for shortcut_set_switch().
+ */
+function shortcut_set_switch_validate($form, &$form_state) {
+  if ($form_state['values']['set'] == 'new') {
+    // check to prevent creating shortcut set with empty label.
+    if (trim($form_state['values']['new']) == '') {
+      form_set_error('new', t('New set name can not be empty.'));
+    }
+    // check to prevent duplicate label.
+    if (shortcut_set_name_is_exists($form_state['values']['new'])) {
+      form_set_error('new', t('The shortcut set %name already exists. Choose another name.', array('%name' => $form_state['values']['new'])));
+    }
+  }
+}
+
+/**
  * Submit handler for shortcut_set_switch().
  */
 function shortcut_set_switch_submit($form, &$form_state) {
@@ -146,6 +162,24 @@ function shortcut_set_switch_submit($for
 }
 
 /**
+ * Check to see whether a shortcut set with given name already exists.
+ *
+ * @param $label
+ *   Human readable name of shortcut set.
+ *
+ * @return
+ *   TURE if exits; FALSE otherwise.
+ */
+function shortcut_set_name_is_exists($label) {
+  foreach (shortcut_sets() as $set) {
+    if ($set->title == $label) {
+      return TRUE;
+    }
+  }
+  return FALSE;
+}
+
+/**
  * Menu page callback: builds the page for administering shortcut sets.
  */
 function shortcut_set_admin() {
@@ -191,6 +225,7 @@ function shortcut_set_add_form($form, &$
     '#type' => 'textfield',
     '#title' => t('Set name'),
     '#description' => t('The new set is created by copying items from your default shortcut set.'),
+    '#required' => TRUE,
   );
 
   $form['actions'] = array('#type' => 'actions');
@@ -203,6 +238,16 @@ function shortcut_set_add_form($form, &$
 }
 
 /**
+ * Validation handler for shortcut_set_add_form().
+ */
+function shortcut_set_add_form_validate($form, &$form_state) {
+  // check to prevent duplicate label.
+  if (shortcut_set_name_is_exists($form_state['values']['new'])) {
+    form_set_error('new', t('The shortcut set %name already exists. Choose another name.', array('%name' => $form_state['values']['new'])));
+  }
+}
+
+/**
  * Submit handler for shortcut_set_add_form().
  */
 function shortcut_set_add_form_submit($form, &$form_state) {
@@ -568,11 +613,20 @@ function shortcut_set_edit_form($form, &
     '#value' => t('Save'),
     '#weight' => 5,
   );
-
   return $form;
 }
 
 /**
+ * Validation handler for shortcut_set_edit_form().
+ */
+function shortcut_set_edit_form_validate($form, &$form_state) {
+  // check to prevent duplicate label.
+  if (shortcut_set_name_is_exists($form_state['values']['title'])) {
+    form_set_error('new', t('The shortcut set %name already exists. Choose another name.', array('%name' => $form_state['values']['title'])));
+  }
+}
+
+/**
  * Submit handler for shortcut_set_edit_form().
  */
 function shortcut_set_edit_form_submit($form, &$form_state) {
