diff --git a/app/src/main/java/info/nightscout/android/utils/ValidatingEditTextPreference.java b/app/src/main/java/info/nightscout/android/utils/ValidatingEditTextPreference.java
new file mode 100644
index 0000000000000000000000000000000000000000..db31c48b209b9b7c7ef0341c1a247594edd0c766
--- /dev/null
+++ b/app/src/main/java/info/nightscout/android/utils/ValidatingEditTextPreference.java
@@ -0,0 +1,78 @@
+package info.nightscout.android.utils;
+
+import android.annotation.TargetApi;
+import android.app.AlertDialog;
+import android.content.Context;
+import android.content.DialogInterface;
+import android.os.Build;
+import android.os.Bundle;
+import android.preference.EditTextPreference;
+import android.util.AttributeSet;
+import android.view.View;
+
+import info.nightscout.android.R;
+
+/**
+ * Created by lgoedhart on 29/05/2016.
+ *
+ * Code found at http://stackoverflow.com/a/31345545
+ */
+public class ValidatingEditTextPreference extends EditTextPreference {
+    @TargetApi(Build.VERSION_CODES.LOLLIPOP)
+    public ValidatingEditTextPreference(Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes) {
+        super(context, attrs, defStyleAttr, defStyleRes);
+    }
+
+    public ValidatingEditTextPreference(Context context, AttributeSet attrs, int defStyleAttr) {
+        super(context, attrs, defStyleAttr);
+    }
+
+    public ValidatingEditTextPreference(Context context, AttributeSet attrs) {
+        super(context, attrs);
+    }
+
+    public ValidatingEditTextPreference(Context context) {
+        super(context);
+    }
+
+    @Override
+    protected void showDialog(Bundle state) {
+        super.showDialog(state);
+        AlertDialog dlg = (AlertDialog) getDialog();
+        View positiveButton = dlg.getButton(DialogInterface.BUTTON_POSITIVE);
+        getEditText().setError(null);
+        positiveButton.setOnClickListener(new View.OnClickListener() {
+            @Override
+            public void onClick(View v) {
+                onPositiveButtonClicked(v);
+            }
+        });
+    }
+
+    private void onPositiveButtonClicked(View v) {
+        String errorMessage = onValidate(getEditText().getText().toString());
+        if (errorMessage == null) {
+            getEditText().setError(null);
+            onClick(getDialog(), DialogInterface.BUTTON_POSITIVE);
+            getDialog().dismiss();
+        } else {
+            getEditText().setError(errorMessage);
+        }
+    }
+
+    /***
+     * Called to validate contents of the edit text.
+     * <p/>
+     * Return null to indicate success, or return a validation error message to display on the edit text.
+     *
+     * @param text The text to validate.
+     * @return An error message, or null if the value passes validation.
+     */
+    public String onValidate(String text) {
+        if (text.length() > 12) {
+            return null;
+        } else {
+            return getContext().getString(R.string.error_msg_api_secret_length);
+        }
+    }
+}
\ No newline at end of file
diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml
index e6e61757d1ecd9bcbbe63835193560c1f64c119f..f0a3a09f14d46179f1126366e4e08d38b0cd5804 100644
--- a/app/src/main/res/values/strings.xml
+++ b/app/src/main/res/values/strings.xml
@@ -38,4 +38,7 @@
     <string name="button_text_clear_log">Clear Log</string>
     <string name="button_text_get_now">Get Now</string>
     <string name="button_text_start_uploading_data">Start Uploading CGM Data</string>
+    <string name="preference_eula_accepted">IUNDERSTAND</string>
+    <string name="preference_enable_rest_upload">EnableRESTUpload</string>
+    <string name="error_msg_api_secret_length">API Secret must be 12 characters or longer.</string>
 </resources>
diff --git a/app/src/main/res/xml/preferences.xml b/app/src/main/res/xml/preferences.xml
index 92bfaaa04b9e282a82edc4afa08964cfa64da51c..96bddb3ddfeccca76ac69efb6f74abe9890175a9 100644
--- a/app/src/main/res/xml/preferences.xml
+++ b/app/src/main/res/xml/preferences.xml
@@ -22,28 +22,28 @@
     <PreferenceCategory android:title="Sharing">
         <info.nightscout.android.utils.CustomSwitchPreference
             android:disableDependentsState="false"
-            android:key="EnableRESTUpload"
+            android:key="@string/preference_enable_rest_upload"
             android:summary="Enable upload of data to Nightscout"
             android:title="REST API Upload"></info.nightscout.android.utils.CustomSwitchPreference>
         <EditTextPreference
             android:defaultValue="https://YOUR.NIGHTSCOUT.SITE"
-            android:dependency="EnableRESTUpload"
+            android:dependency="@string/preference_enable_rest_upload"
             android:dialogMessage="The hostname of your Nightscout site"
             android:dialogTitle="Enter Nightscout URL"
             android:key="@string/preference_nightscout_url"
             android:title="Nightscout URL"></EditTextPreference>
-        <EditTextPreference
+        <info.nightscout.android.utils.ValidatingEditTextPreference
             android:defaultValue="YOURAPISECRET"
-            android:dependency="EnableRESTUpload"
+            android:dependency="@string/preference_enable_rest_upload"
             android:dialogMessage="Your Nightscout API secret"
             android:dialogTitle="Enter your Nightscout API secret"
             android:key="@string/preference_api_secret"
-            android:title="API Secret"></EditTextPreference>
+            android:title="API Secret"></info.nightscout.android.utils.ValidatingEditTextPreference>
     </PreferenceCategory>
     <PreferenceCategory android:title="Disclaimer">
         <info.nightscout.android.utils.CustomSwitchPreference
             android:disableDependentsState="false"
-            android:key="IUNDERSTAND"
+            android:key="@string/preference_eula_accepted"
             android:summaryOff="Deactivated. Nightscout should not be used to make medical decisions. There is no support or any warranty of any kind. The quality and performance of the project is with you. This is a project that was created and is supported completely by volunteers"
             android:summaryOn="Activated. Nightscout should not be used to make medical decisions. There is no support or any warranty of any kind. The quality and performance of the project is with you. This is a project that was created and is supported completely by volunteers"
             android:switchTextOff="NO"