performing common form field validation tasks : Context « Core Class « Android






performing common form field validation tasks

     
package mobilesmil.utils;

import android.app.AlertDialog;
import android.content.Context;
import android.content.DialogInterface;

/**
 * Utilities and variables for performing common form field validation tasks.
 * @author Ryan Ware
 *
 */
public class FormValidationUtils {
  
  public static final String INTEGER_REGEX = "\\d+";
  public static final char[] INVALID_FILENAME_CHARS = new char[]{
    '\\','/','?','\"','\'','<','>',':','*','|','\t','\n','\r'
  };
  
  /**
   * Creates an {@link AlertDialog} for notifying the user of an invalid form.
   * @param context {@link Context} of this dialog
   * @return {@link AlertDialog} invalid form field dialog
   */
  public static AlertDialog createInvalidFormDialog(Context context) {
    AlertDialog.Builder dialogBuilder = new AlertDialog.Builder(context);
      dialogBuilder.setIcon(android.R.drawable.ic_dialog_alert);
        dialogBuilder.setPositiveButton("OK", new DialogInterface.OnClickListener() {
          public void onClick(DialogInterface dialog, int which) {
            return; // button simply closes the dialog
          } });
        return dialogBuilder.create();
  }
}

   
    
    
    
    
  








Related examples in the same category

1.Context.MODE_WORLD_READABLE
2.Returns whether the context is running on the android emulator.
3.check Internet for Context
4.add Link
5.Reads all text from asset with specified path.
6.Context Delete File
7.Context Open file
8.Context.openFileOutput