diff --git a/includes/form.inc b/includes/form.inc
index 8f2ee26..1f622bb 100644
--- a/includes/form.inc
+++ b/includes/form.inc
@@ -3058,6 +3058,50 @@ function form_process_actions($element, &$form_state) {
 }
 
 /**
+ * Processes a form elements pattern.
+ *
+ * @param $element
+ *   An associative array containing the properties and children of the
+ *   form actions container.
+ * @param $form_state
+ *   The $form_state array for the form this element belongs to.
+ *
+ * @return
+ *   The processed element.
+ */
+function element_process_pattern($element, &$form_state) {
+  if (isset($element['#pattern'])) {
+    $element['#attributes']['pattern'] = $element['#pattern'];
+    $element['element_validate'][] = 'element_validate_patten';
+  }
+
+  return $element;
+}
+
+/**
+ * Validate a form elements pattern.
+ *
+ * @param $element
+ *   An associative array containing the properties and children of the
+ *   form actions container.
+ * @param $form_state
+ *   The $form_state array for the form this element belongs to.
+ *
+ * @return
+ *   The processed element.
+ */
+function element_validate_patten($element, &$form_state) {
+  if (isset($element['#pattern'])) {
+    $value = $element['#value'];
+    if (!mb_ereg($pattern['#pattern'], $value)) {
+      form_error($element, t('%name is not valid.', array('%name' => $element['#title'])));
+    }
+  }
+
+  return $element;
+}
+
+/**
  * Processes a container element.
  *
  * @param $element
diff --git a/modules/system/system.module b/modules/system/system.module
index 3ebc657..40db783 100644
--- a/modules/system/system.module
+++ b/modules/system/system.module
@@ -351,7 +351,7 @@ function system_element_info() {
     '#size' => 60,
     '#maxlength' => 128,
     '#autocomplete_path' => FALSE,
-    '#process' => array('ajax_process_form'),
+    '#process' => array('ajax_process_form', 'element_process_pattern'),
     '#theme' => 'textfield',
     '#theme_wrappers' => array('form_element'),
   );
