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