001: /*
002: * GWT-Ext Widget Library
003: * Copyright(c) 2007-2008, GWT-Ext.
004: * licensing@gwt-ext.com
005: *
006: * http://www.gwt-ext.com/license
007: */
008:
009: package com.gwtext.client.widgets.form;
010:
011: import com.gwtext.client.core.RegExp;
012:
013: //http://extjs.com/forum/showthread.php?t=4271&highlight=vtype
014: /**
015: * Basic pre-created validation types. Overridable validation definitions. The validations provided are basic and
016: * intended to be easily customizable and extended.
017: *
018: * @see com.gwtext.client.widgets.form.TextField#setVtype(VType)
019: */
020: public class VType {
021:
022: private String vType;
023:
024: private VType(String vType) {
025: this .vType = vType;
026: }
027:
028: public String getVType() {
029: return vType;
030: }
031:
032: /**
033: * The function used to validate alpha values
034: */
035: public static VType ALPHA = new VType("alpha");
036:
037: /**
038: * The function used to validate alphanumeric values.
039: */
040: public static VType ALPHANUM = new VType("alphanum");
041:
042: /**
043: * The function used to validate email addresses.
044: */
045: public static VType EMAIL = new VType("email");
046:
047: /**
048: * The function used to validate URLs.
049: */
050: public static VType URL = new VType("url");
051:
052: /**
053: * The error text to display when the alpha validation function returns false.
054: *
055: * @param alphaText error message
056: */
057: public static native void setAlphaText(String alphaText)/*-{
058: $wnd.Ext.form.VTypes.alphaText = alphaText;
059: }-*/;
060:
061: /**
062: * The keystroke filter mask to be applied on alpha input.
063: *
064: * @param alphaMask the alpha mask
065: */
066: public static native void setAlphaMask(RegExp alphaMask)/*-{
067: var re = alphaMask.@com.gwtext.client.core.JsObject::getJsObj()();
068: $wnd.Ext.form.VTypes.alphaMask = re;
069: }-*/;
070:
071: /**
072: * The error text to display when the alphanumeric validation function returns false.
073: *
074: * @param alphanumText the error message
075: */
076: public static native void setAlphanumText(String alphanumText)/*-{
077: $wnd.Ext.form.VTypes.alphanumText = alphanumText;
078: }-*/;
079:
080: /**
081: * The keystroke filter mask to be applied on alphanumeric input.
082: *
083: * @param alphanumMask the alpha num mask
084: */
085: public static native void setAlphanumMask(RegExp alphanumMask)/*-{
086: var re = alphanumMask.@com.gwtext.client.core.JsObject::getJsObj()();
087: $wnd.Ext.form.VTypes.alphanumMask = re;
088: }-*/;
089:
090: /**
091: * The error text to display when the email validation function returns false.
092: *
093: * @param emailText the error message
094: */
095: public static native void setEmailText(String emailText)/*-{
096: $wnd.Ext.form.VTypes.emailText = emailText;
097: }-*/;
098:
099: /**
100: * The keystroke filter mask to be applied on email input.
101: *
102: * @param emailMask the email mask
103: */
104: public static native void setEmailMask(RegExp emailMask)/*-{
105: var re = emailMask.@com.gwtext.client.core.JsObject::getJsObj()();
106: $wnd.Ext.form.VTypes.emailMask = re;
107: }-*/;
108:
109: /**
110: * The error text to display when the url validation function returns false.
111: *
112: * @param urlText the error message
113: */
114: public static native void setUrlText(String urlText)/*-{
115: $wnd.Ext.form.VTypes.urlText = urlText;
116: }-*/;
117:
118: }
|