Forms 6i Validation Question

Hi all,
Here's the scenario: I have a field in which the first 2-digits entered can only be values AB, CC, DD as well as any 2-digit number. Please give me an example of how to write a query for this. I have an idea on how to code the AB, CC and DD values, but I am not sure how to code the form to also accept any 2-digit number.
Thanks

... OR ...
I am grinning here... Why don't you try your version and see?
When I started programming close to 30 years ago, I would always stumble over that problem. It is quite confusing, so I'll try to explain. The basic rule is: ALWAYS use AND between two NOT conditions. If you use OR, the pair will ALWAYS be true.
If you put OR between the two conditions, then
... if your value is AB, the first line C1 is false and the second line C2 is true, so:
If C1 or C2 becomes TRUE.
...if your value is 12, the first line C1 is true and the second line C2 is false, so:
If C1 or C2 becomes TRUE.
...if your value is XX, both C1 and C2 are true, so:
If C1 or C2 becomes TRUE.
Your OR will cause the condition to flag the value in error every time. So AND is the answer -- you only have an error if BOTH are true, as when your value is XX above.

Similar Messages

  • Form Entry Validation Question

    I want to validate a numeric field entry as either blank or zero (whichever is the default value in a numeric form field) or a particular number (i.e., 5).  Can someone tell me the proper javascript code?

    I want to validate a numeric field entry as either blank or zero (whichever is the default value in a numeric form field) or a particular number (i.e., 5).  Can someone tell me the proper javascript code?

  • Validation questions: How to turn it off, and how to check to see if a form is valid

    Hi all,
    I'm looking for some assistance with validation on a form / Form guide. Basically there are two things that we need to be able to do.
    1) We need to be able to disable all the validation on a given form / Form Guide so that we can perform a submit operation to save all the data currently on the form.
    2) We also need to be able to make the determination of whether or not a form is valid. The validity of the form would be passed with the form during the submit process.
    Towards that end, I have been looking into the properties "validationsEnbled" and "disableAll". Neither one of which seem to do anything at all.
    Any assistance you could provide would be greatly appreciated.
    Thanks in Advance.
    Steve

    Okay here's a nice little function I wrote to turn off all the mandatory fields in your form.
    function unMandatoryAll() {
        //makes all mandatory fields not mandatory anymore
        var oFormRoot = xfa.form.nodes.item(0);
        var arrMandatoryFieldNames = findMandatories(oFormRoot, new Array());
        for (var i=0; i<arrMandatoryFieldNames.length; i++) {
            var oCurrentField = xfa.resolveNode(arrMandatoryFieldNames[i]);
            oCurrentField.validate.nullTest = "disabled";
    function findMandatories(oFormNode, arrMandatoryFieldNames) {
        //loops recursively through all fields in the given oFormNode and builds up a list of field names (actually SOM expressions)
        var oChildNodes = oFormNode.nodes;
        var nNumberOfChildNodes = oChildNodes.length;
        for (var i=0; i<nNumberOfChildNodes; i++) {
            var oCurrentNode = oChildNodes.item(i);
            var strNodeType = oCurrentNode.className;
            if (strNodeType == "subform")
                arrMandatoryFieldNames = findMandatories(oCurrentNode, arrMandatoryFieldNames);
            if ((strNodeType == "field") || (strNodeType == "exclGroup")) {
                if (oCurrentNode.validate.nullTest == "error")
                    arrMandatoryFieldNames.push(oCurrentNode.somExpression);
        return arrMandatoryFieldNames;
    Jared Langdon
    http://www.jlangdon.ca

  • Preventing ADF Input Form from validating

    Can anyone say how can i prevent an ADF Creation Form from validating the inputText fields when there is no data entered in any of the fields and the user press a Cancel button to cancel the input and return/navigate to another page???
    Currently when i try that that the fields are validates and a message is displayed saying the field requires a value. And it will not allow me to navigate to another page unless some value is entered. Why is this so ?
    Thanks

    I figured this out myself, actually this was quite simple.- just set the 'immediate' property on the component (button) to 'true'.

  • Hi! I have a Creative suite Design Standard 9 Adobe program and I am attempting to make a wizzard form that can be made into an entry form for a competition. So I need to 1. Make the form into a question and answer form that Participants may fill out. 2.

    Hi! I have a Creative suite Design Standard 9 Adobe program and I am attempting to make a wizzard form that can be made into an entry form for a competition. So I need to 1. Make the form into a question and answer form that Participants may fill out. 2. make it possible for them to download it via a link on our website 3. make it possible for them to save the info they have written into the form and mail it to the mail we have supplied in the entry form and 4. make it possible for them to put in a jpg. as part of the entry for and lastly 5. make it possible for us to copy paste the document and use it on other platforms. How do I do this - is it at all possible with adobe?

    Those requirements are go way beyond what PDF forms can do and are meant for, some of them would require involving other programs or are mutually exclusive and contradictory. You are wasting your time even thinking about doing this as an "offline" PDF form. Simply sign up for an online forms/ survey service like FormsCentral or Surveymonkey.
    Mylenium

  • Determining whether form is valid or not

    Assuming I have a form with few input fields,
    I want to render a button only when the form is valid using ajax calls,
    Is it possible somehow to determine whether a form is valid or not?
    Thanks,
    Asaf.

    When a form is submitted and the JSF validation phase pass successfully and jsf cycle moves to the update model values,
    I have several rules like some required fields, several validators attached to input fields, etc...
    if all validators / required fields are set I would like to render a 'submit' button.
    Asaf.

  • FORMS d2k interview questions

    Hi All,
    Please provide me links or files regarding interview questions on Oracle FORMS 10g from basics to advance level so
    the my complete forms development is revised in form of Q and As.
    Thanks
    ANSHUL ,INDIA

    1. Open a browser on PC that has internet access
    2. Go to www.google.com or www.google.co.in or any other search engine of your choice
    3. Enter key words "oracle forms 10g interview questions and answers" , without the quotes
    4. Go through the links displayed
    Regards,

  • Forms 6i interview questions

    If any body have forms 6i interview questions pl
    mail me at [email protected]

    The following book has a couple chapters of interview questions divided into "Beginner" and "Advanced:"
    Oracle Developer Advanced Forms and Reports.
    Koletzke, Peter and Dorsey, Paul.
    Oracle Press: Osborne/McGraw-Hill. (ISBN: 0-07-212048-7)
    MH

  • I need dynamic form string validation?

    hai friends,
    dynamic form string validation for
    below code
    var  
    resdata1:ArrayCollection=event.result.RES1; 
    for(i=0;i<resdata1.length;i++){
    pn.visible=
    false; 
    var formlabel:String= resdata1[i].spk_name; 
    frmitem =
    new FormItem();frmitem.direction =
    "horizontal";frmitem.required=
    true;frmitem.label = formlabel;
    if(resdata1[i].hasOptionsList==null){
    txtinput =
    new TextInput();txtinput.id= "txt"+resdata1[i].spk_name;
    frmitem.addChild(txtinput);
    else
    newcb=
    new ComboBox(); 
    var tempdata:ArrayCollection=resdata1[i].ruleName; 
    //newcb.dataProvider=bindata;
    newcb.dataProvider=tempdata;
    newcb.labelField=
    "spko_value";frmitem.addChild(newcb);
    FormContainer.addChild(frmitem);
    pn.visible=
    true;pn.title=resdata1[0].ProfileName;

    Hi,
    Try this. Hopefully this will help you.
    private function createDynamicForm():void{
                    var myForm:Form=new Form();
                    var frmNameItem:FormItem=new FormItem();
                    frmNameItem.label = "Name";
                    var myText:TextInput = new TextInput();
                    frmNameItem.addChild(myText);
                    myForm.addChild(frmNameItem);
                    var myButton:Button=new Button();
                    myButton.label = "Save";
                    myForm.addChild(myButton);
                    this.addChild(myForm);

  • On a form w Validation, how to redirect to a custom page

    Hi. I have created a form in Dreamweaver CS5 that uses spry validation successfully. Once the form is submitted, the user is redirected to the home page. But I don't want that redirect.
    My question is, how can I have the validated page redirect to a custom thank you page I designed? I don't know the exact code/syntax to write to make it do what I want and, even if I had the code, I wouldn't know exactly where it should be placed. Please help if you can. Here's the source code. )BTW, when I use Dreamweaver Behaviors to add a URL redirect, it ignores the required validation and simply allows you to click the submit button and redirect.) Many thanks!
    <!DOCTYPE HTML>
    <html>
    <head>
    <meta charset="UTF-8">
    <link href="../_css/main.css" rel="stylesheet" media="screen, projection">
    <link href="../_css/forms.css" rel="stylesheet" media="screen, projection">
    <title></title>
    <!--[if lt IE 9]>
    <script src="http://ie7-js.googlecode.com/svn/version/2.1(beta4)/IE9.js"></script><![endif]-->
    <script src="../SpryAssets/SpryValidationTextField.js" type="text/javascript"></script>
    <link href="../SpryAssets/SpryValidationTextField.css" rel="stylesheet" type="text/css">
    <script type="text/javascript">
    <!-- **** I think the line of code for the redirect is here??...I just don't know how to write the code to redirect to the page I want ***** -->
    function MM_goToURL() { //v3.0
      var i, args=MM_goToURL.arguments; document.MM_returnValue = false;
      for (i=0; i<(args.length-1); i+=2) eval(args[i]+".location='"+args[i+1]+"'");
    </script>
    </head>
    <body>
    <header id="pageHeader">
    <a href="../index.htm"><img src="../_images/logo.gif" width="170" height="91" alt="HMN logo" id="logo"></a>
    <img src="../_images/tagline.png" width="296" height="92" alt="HMN tagline" id="tagline">
    </header>
    <nav id="mainNav">
    <ul>
    <li><a href="../index.htm">Home</a></li>
    <li><a href="../press.htm">Press</a></li>
    <li><a href="../about.htm">About</a></li>
    <li><a href="../contact.htm">Contact</a></li>
    </ul>
    </nav>
    <br class="clear">
    <div class="headerContact">
    </div>
    <article>
      <!-- The file webformmailer.php sits on the web server at godaddy.com in case that matters -->
    <section id="Request">
    <p id="intro">To request your link for the downloadable <span id="highlight">Media Kit</span>, please provide the following information:</p>
    <form name="Request" method="post" action="../../webformmailer.php"> <p id="formCaption">Fields marked with * are required.</p>
      <p><span id="sprytextfield1">
        <label for="first_name">First Name:*</label>
        <input type="text" name="first_name" id="first_name">
        <span class="textfieldRequiredMsg">(required)</span></span></p>
      <p><span id="sprytextfield2">
        <label for="last_name">Last Name:*</label>
        <input type="text" name="last_name" id="last_name">
        <span class="textfieldRequiredMsg">(required)</span></span></p>
      <p><span id="sprytextfield3">
        <label for="company">Company:*</label>
        <input type="text" name="company" id="company">
        <span class="textfieldRequiredMsg">(required)</span></span></p>
      <p>
        <label for="address">Address:</label>
        <input type="text" name="address" id="address">
      </p>
      <p>
        <label for="address_2">Address 2:</label>
        <input type="text" name="address_2" id="address_2">
      </p>
      <p>
        <label for="city">City:</label>
        <input type="text" name="city" id="city">
      </p>
      <p>
        <label for="state">State:</label>
        <input type="text" name="state" id="state">
      </p>
      <p>
        <label for="zip">Zip:</label>
        <input type="text" name="zip" id="zip">
      </p>
      <p><span id="sprytextfield4">
      <label for="email">Email:*</label>
      <input type="text" name="email" id="email">
      <span class="textfieldRequiredMsg">(required)</span><span class="textfieldInvalidFormatMsg">Invalid format.</span></span> </p>
      <p>
      <input name="submit" type="image" id="submit" onClick="MM_goToURL('parent','media_kit_download.htm');return document.MM_returnValue" src="../_images/btn_submit.png">
      </p>
      <p> </p>
    </form>
    <p>
    </p>
    </div>
    </div>
    </section>
    </article>
    <script type="text/javascript">
    var sprytextfield1 = new Spry.Widget.ValidationTextField("sprytextfield1", "none", {validateOn:["blur"]});
    var sprytextfield2 = new Spry.Widget.ValidationTextField("sprytextfield2", "none", {validateOn:["blur"]});
    var sprytextfield3 = new Spry.Widget.ValidationTextField("sprytextfield3", "none", {validateOn:["blur"]});
    var sprytextfield4 = new Spry.Widget.ValidationTextField("sprytextfield4", "email", {validateOn:["blur"]});
    </script>
    </body>
    </html>

    Thanks for replying. The  URL you've bolded is actually the correct page I'd like the redirect to go to when the form is successfully submitted after validation. But for some reason, that URL request is being ignored and the redirect brings me back to the index page in the root directory. I don't see anywhere in the code that makes the request to do that. Unless that's a default behavior if I've gotten the redirect wrong?
    I don't know if this is helpful, but there is also a .js file that Dreamweaver created and attached to the above HTML source file. The .js file appears to have all the spry code validation including code for features and widgets I'm not even using. I searched through the code several times trying to identify where there might be a redirect to the index page but didn't recognize anything that made sense to me. Here is the complete, unedited file:
    // SpryValidationTextField.js - version 0.38 - Spry Pre-Release 1.6.1
    // Copyright (c) 2006. Adobe Systems Incorporated.
    // All rights reserved.
    // Redistribution and use in source and binary forms, with or without
    // modification, are permitted provided that the following conditions are met:
    //   * Redistributions of source code must retain the above copyright notice,
    //     this list of conditions and the following disclaimer.
    //   * Redistributions in binary form must reproduce the above copyright notice,
    //     this list of conditions and the following disclaimer in the documentation
    //     and/or other materials provided with the distribution.
    //   * Neither the name of Adobe Systems Incorporated nor the names of its
    //     contributors may be used to endorse or promote products derived from this
    //     software without specific prior written permission.
    // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
    // AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
    // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
    // ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
    // LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
    // CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
    // SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
    // INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
    // CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
    // ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
    // POSSIBILITY OF SUCH DAMAGE.
    (function() { // BeginSpryComponent
    if (typeof Spry == "undefined") window.Spry = {}; if (!Spry.Widget) Spry.Widget = {};
    Spry.Widget.BrowserSniff = function()
        var b = navigator.appName.toString();
        var up = navigator.platform.toString();
        var ua = navigator.userAgent.toString();
        this.mozilla = this.ie = this.opera = this.safari = false;
        var re_opera = /Opera.([0-9\.]*)/i;
        var re_msie = /MSIE.([0-9\.]*)/i;
        var re_gecko = /gecko/i;
        var re_safari = /(applewebkit|safari)\/([\d\.]*)/i;
        var r = false;
        if ( (r = ua.match(re_opera))) {
            this.opera = true;
            this.version = parseFloat(r[1]);
        } else if ( (r = ua.match(re_msie))) {
            this.ie = true;
            this.version = parseFloat(r[1]);
        } else if ( (r = ua.match(re_safari))) {
            this.safari = true;
            this.version = parseFloat(r[2]);
        } else if (ua.match(re_gecko)) {
            var re_gecko_version = /rv:\s*([0-9\.]+)/i;
            r = ua.match(re_gecko_version);
            this.mozilla = true;
            this.version = parseFloat(r[1]);
        this.windows = this.mac = this.linux = false;
        this.Platform = ua.match(/windows/i) ? "windows" :
                        (ua.match(/linux/i) ? "linux" :
                        (ua.match(/mac/i) ? "mac" :
                        ua.match(/unix/i)? "unix" : "unknown"));
        this[this.Platform] = true;
        this.v = this.version;
        if (this.safari && this.mac && this.mozilla) {
            this.mozilla = false;
    Spry.is = new Spry.Widget.BrowserSniff();
    Spry.Widget.ValidationTextField = function(element, type, options)
        type = Spry.Widget.Utils.firstValid(type, "none");
        if (typeof type != 'string') {
            this.showError('The second parameter in the constructor should be the validation type, the options are the third parameter.');
            return;
        if (typeof Spry.Widget.ValidationTextField.ValidationDescriptors[type] == 'undefined') {
            this.showError('Unknown validation type received as the second parameter.');
            return;
        options = Spry.Widget.Utils.firstValid(options, {});
        this.type = type;
        if (!this.isBrowserSupported()) {
            //disable character masking and pattern behaviors for low level browsers
            options.useCharacterMasking = false;
        this.init(element, options);
        //make sure we validate at least on submit
        var validateOn = ['submit'].concat(Spry.Widget.Utils.firstValid(this.options.validateOn, []));
        validateOn = validateOn.join(",");
        this.validateOn = 0;
        this.validateOn = this.validateOn | (validateOn.indexOf('submit') != -1 ? Spry.Widget.ValidationTextField.ONSUBMIT : 0);
        this.validateOn = this.validateOn | (validateOn.indexOf('blur') != -1 ? Spry.Widget.ValidationTextField.ONBLUR : 0);
        this.validateOn = this.validateOn | (validateOn.indexOf('change') != -1 ? Spry.Widget.ValidationTextField.ONCHANGE : 0);
        if (Spry.Widget.ValidationTextField.onloadDidFire)
            this.attachBehaviors();
        else
            Spry.Widget.ValidationTextField.loadQueue.push(this);
    Spry.Widget.ValidationTextField.ONCHANGE = 1;
    Spry.Widget.ValidationTextField.ONBLUR = 2;
    Spry.Widget.ValidationTextField.ONSUBMIT = 4;
    Spry.Widget.ValidationTextField.ERROR_REQUIRED = 1;
    Spry.Widget.ValidationTextField.ERROR_FORMAT = 2;
    Spry.Widget.ValidationTextField.ERROR_RANGE_MIN = 4;
    Spry.Widget.ValidationTextField.ERROR_RANGE_MAX = 8;
    Spry.Widget.ValidationTextField.ERROR_CHARS_MIN = 16;
    Spry.Widget.ValidationTextField.ERROR_CHARS_MAX = 32;
    /* validation parameters:
    *  - characterMasking : prevent typing of characters not matching an regular expression
    *  - regExpFilter : additional regular expression to disalow typing of characters
    *        (like the "-" sign in the middle of the value); use for partial matching of the currently typed value;
    *         the typed value must match regExpFilter at any moment
    *  - pattern : enforce character on each position inside a pattern (AX0?)
    *  - validation : function performing logic validation; return false if failed and the typedValue value on success
    *  - minValue, maxValue : range validation; check if typedValue inside the specified range
    *  - minChars, maxChars : value length validation; at least/at most number of characters
    Spry.Widget.ValidationTextField.ValidationDescriptors = {
        'none': {
        'custom': {
        'integer': {
            characterMasking: /[\-\+\d]/,
            regExpFilter: /^[\-\+]?\d*$/,
            validation: function(value, options) {
                if (value == '' || value == '-' || value == '+') {
                    return false;
                var regExp = /^[\-\+]?\d*$/;
                if (!regExp.test(value)) {
                    return false;
                options = options || {allowNegative:false};
                var ret = parseInt(value, 10);
                if (!isNaN(ret)) {
                    var allowNegative = true;
                    if (typeof options.allowNegative != 'undefined' && options.allowNegative == false) {
                        allowNegative = false;
                    if (!allowNegative && value < 0) {
                        ret = false;
                } else {
                    ret = false;
                return ret;
        'real': {
            characterMasking: /[\d\.,\-\+e]/i,
            regExpFilter: /^[\-\+]?\d(?:|\.,\d{0,2})|(?:|e{0,1}[\-\+]?\d{0,})$/i,
            validation: function (value, options) {
                var regExp = /^[\+\-]?[0-9]+([\.,][0-9]+)?([eE]{0,1}[\-\+]?[0-9]+)?$/;
                if (!regExp.test(value)) {
                    return false;
                var ret = parseFloat(value);
                if (isNaN(ret)) {
                    ret = false;
                return ret;
        'currency': {
            formats: {
                'dot_comma': {
                    characterMasking: /[\d\.\,\-\+\$]/,
                    regExpFilter: /^[\-\+]?(?:[\d\.]*)+(|\,\d{0,2})$/,
                    validation: function(value, options) {
                        var ret = false;
                        //2 or no digits after the comma
                        if (/^(\-|\+)?\d{1,3}(?:\.\d{3})*(?:\,\d{2}|)$/.test(value) || /^(\-|\+)?\d+(?:\,\d{2}|)$/.test(value)) {
                            value = value.toString().replace(/\./gi, '').replace(/\,/, '.');
                            ret = parseFloat(value);
                        return ret;
                'comma_dot': {
                    characterMasking: /[\d\.\,\-\+\$]/,
                    regExpFilter: /^[\-\+]?(?:[\d\,]*)+(|\.\d{0,2})$/,
                    validation: function(value, options) {
                        var ret = false;
                        //2 or no digits after the comma
                        if (/^(\-|\+)?\d{1,3}(?:\,\d{3})*(?:\.\d{2}|)$/.test(value) || /^(\-|\+)?\d+(?:\.\d{2}|)$/.test(value)) {
                            value = value.toString().replace(/\,/gi, '');
                            ret = parseFloat(value);
                        return ret;
        'email': {
            characterMasking: /[^\s]/,
            validation: function(value, options) {
                var rx = /^[\w\.-]+@[\w\.-]+\.\w+$/i;
                return rx.test(value);
        'date': {
            validation: function(value, options) {
                var formatRegExp = /^([mdy]+)[\.\-\/\\\s]+([mdy]+)[\.\-\/\\\s]+([mdy]+)$/i;
                var valueRegExp = this.dateValidationPattern;
                var formatGroups = options.format.match(formatRegExp);
                var valueGroups = value.match(valueRegExp);
                if (formatGroups !== null && valueGroups !== null) {
                    var dayIndex = -1;
                    var monthIndex = -1;
                    var yearIndex = -1;
                    for (var i=1; i<formatGroups.length; i++) {
                        switch (formatGroups[i].toLowerCase()) {
                            case "dd":
                                dayIndex = i;
                                break;
                            case "mm":
                                monthIndex = i;
                                break;
                            case "yy":
                            case "yyyy":
                                yearIndex = i;
                                break;
                    if (dayIndex != -1 && monthIndex != -1 && yearIndex != -1) {
                        var maxDay = -1;
                        var theDay = parseInt(valueGroups[dayIndex], 10);
                        var theMonth = parseInt(valueGroups[monthIndex], 10);
                        var theYear = parseInt(valueGroups[yearIndex], 10);
                        // Check month value to be between 1..12
                        if (theMonth < 1 || theMonth > 12) {
                            return false;
                        // Calculate the maxDay according to the current month
                        switch (theMonth) {
                            case 1:    // January
                            case 3: // March
                            case 5: // May
                            case 7: // July
                            case 8: // August
                            case 10: // October
                            case 12: // December
                                maxDay = 31;
                                break;
                            case 4:    // April
                            case 6: // June
                            case 9: // September
                            case 11: // November
                                maxDay = 30;
                                break;
                            case 2: // February
                                if ((parseInt(theYear/4, 10) * 4 == theYear) && (theYear % 100 != 0 || theYear % 400 == 0)) {
                                    maxDay = 29;
                                } else {
                                    maxDay = 28;
                                break;
                        // Check day value to be between 1..maxDay
                        if (theDay < 1 || theDay > maxDay) {
                            return false;
                        // If successfull we'll return the date object
                        return (new Date(theYear, theMonth - 1, theDay));   //JavaScript requires a month between 0 and 11
                } else {
                    return false;
        'time': {
            validation: function(value, options) {
                //    HH:MM:SS T
                var formatRegExp = /([hmst]+)/gi;
                var valueRegExp = /(\d+|AM?|PM?)/gi;
                var formatGroups = options.format.match(formatRegExp);
                var valueGroups = value.match(valueRegExp);
                //mast match and have same length
                if (formatGroups !== null && valueGroups !== null) {
                    if (formatGroups.length != valueGroups.length) {
                        return false;
                    var hourIndex = -1;
                    var minuteIndex = -1;
                    var secondIndex = -1;
                    //T is AM or PM
                    var tIndex = -1;
                    var theHour = 0, theMinute = 0, theSecond = 0, theT = 'AM';
                    for (var i=0; i<formatGroups.length; i++) {
                        switch (formatGroups[i].toLowerCase()) {
                            case "hh":
                                hourIndex = i;
                                break;
                            case "mm":
                                minuteIndex = i;
                                break;
                            case "ss":
                                secondIndex = i;
                                break;
                            case "t":
                            case "tt":
                                tIndex = i;
                                break;
                    if (hourIndex != -1) {
                        var theHour = parseInt(valueGroups[hourIndex], 10);
                        if (isNaN(theHour) || theHour > (formatGroups[hourIndex] == 'HH' ? 23 : 12 )) {
                            return false;
                    if (minuteIndex != -1) {
                        var theMinute = parseInt(valueGroups[minuteIndex], 10);
                        if (isNaN(theMinute) || theMinute > 59) {
                            return false;
                    if (secondIndex != -1) {
                        var theSecond = parseInt(valueGroups[secondIndex], 10);
                        if (isNaN(theSecond) || theSecond > 59) {
                            return false;
                    if (tIndex != -1) {
                        var theT = valueGroups[tIndex].toUpperCase();
                        if (
                            formatGroups[tIndex].toUpperCase() == 'TT' && !/^a|pm$/i.test(theT) ||
                            formatGroups[tIndex].toUpperCase() == 'T' && !/^a|p$/i.test(theT)
                            return false;
                    var date = new Date(2000, 0, 1, theHour + (theT.charAt(0) == 'P'?12:0), theMinute, theSecond);
                    return date;
                } else {
                    return false;
        'credit_card': {
            characterMasking: /\d/,
            validation: function(value, options) {
                var regExp = null;
                options.format = options.format || 'ALL';
                switch (options.format.toUpperCase()) {
                    case 'ALL': regExp = /^[3-6]{1}[0-9]{12,18}$/; break;
                    case 'VISA': regExp = /^4(?:[0-9]{12}|[0-9]{15})$/; break;
                    case 'MASTERCARD': regExp = /^5[1-5]{1}[0-9]{14}$/; break;
                    case 'AMEX': regExp = /^3(4|7){1}[0-9]{13}$/; break;
                    case 'DISCOVER': regExp = /^6011[0-9]{12}$/; break;
                    case 'DINERSCLUB': regExp = /^3(?:(0[0-5]{1}[0-9]{11})|(6[0-9]{12})|(8[0-9]{12}))$/; break;
                if (!regExp.test(value)) {
                    return false;
                var digits = [];
                var j = 1, digit = '';
                for (var i = value.length - 1; i >= 0; i--) {
                    if ((j%2) == 0) {
                        digit = parseInt(value.charAt(i), 10) * 2;
                        digits[digits.length] = digit.toString().charAt(0);
                        if (digit.toString().length == 2) {
                            digits[digits.length] = digit.toString().charAt(1);
                    } else {
                        digit = value.charAt(i);
                        digits[digits.length] = digit;
                    j++;
                var sum = 0;
                for(i=0; i < digits.length; i++ ) {
                    sum += parseInt(digits[i], 10);
                if ((sum%10) == 0) {
                    return true;
                return false;
        'zip_code': {
            formats: {
                'zip_us9': {
                    pattern:'00000-0000'
                'zip_us5': {
                    pattern:'00000'
                'zip_uk': {
                    characterMasking: /[\dA-Z\s]/,
                    validation: function(value, options) {
                        //check one of the following masks
                        // AN NAA, ANA NAA, ANN NAA, AAN NAA, AANA NAA, AANN NAA
                        return /^[A-Z]{1,2}\d[\dA-Z]?\s?\d[A-Z]{2}$/.test(value);
                'zip_canada': {
                    characterMasking: /[\dA-Z\s]/,
                    pattern: 'A0A 0A0'
                'zip_custom': {}
        'phone_number': {
            formats: {
                //US phone number; 10 digits
                'phone_us': {
                    pattern:'(000) 000-0000'
                'phone_custom': {}
        'social_security_number': {
            pattern:'000-00-0000'
        'ip': {
            characterMaskingFormats: {
                'ipv4': /[\d\.]/i,
                'ipv6_ipv4': /[\d\.\:A-F\/]/i,
                'ipv6': /[\d\.\:A-F\/]/i
            validation: function (value, options) {
                return Spry.Widget.ValidationTextField.validateIP(value, options.format);
        'url': {
            characterMasking: /[^\s]/,
            validation: function(value, options) {
                //fix for ?ID=223429 and ?ID=223387
                /* the following regexp matches components of an URI as specified in http://tools.ietf.org/html/rfc3986#page-51 page 51, Appendix B.
                    scheme    = $2
                    authority = $4
                    path      = $5
                    query     = $7
                    fragment  = $9
                var URI_spliter = /^(([^:\/?#]+):)?(\/\/([^\/?#]*))?([^?#]*)(\?([^#]*))?(#(.*))?/;
                var parts = value.match(URI_spliter);
                if (parts && parts[4]) {
                    //encode each component of the domain name using Punycode encoding scheme: http://tools.ietf.org/html/rfc3492
                    var host  = parts[4].split(".");
                    var punyencoded = '';
                    for (var i=0; i<host.length; i++) {
                        punyencoded = Spry.Widget.Utils.punycode_encode(host[i], 64);
                        if (!punyencoded) {
                            return false;
                        } else {
                            if (punyencoded != (host[i] + "-")) {
                                host[i] = 'xn--' + punyencoded;
                    host = host .join(".");
                    //the encoded domain name is replaced into the original URL to be validated again later as URL
                    value = value.replace(URI_spliter, "$1//" + host + "$5$6$8");
                //fix for ?ID=223358 and ?ID=223594
                //the following validates an URL using ABNF rules as defined in http://tools.ietf.org/html/rfc3986 , Appendix A., page 49
                //except host which is extracted by match[1] and validated separately
                 * userinfo=    (?:(?:[a-z0-9\-\._~\!\$\&\'\(\)\*\+\,\;\=:]|%[0-9a-f]{2,2})*\@)?
                 * host=            (?:((?:(?:[a-z0-9][a-z0-9\-]*[a-z0-9]|[a-z0-9])\.)*(?:[a-z][a-z0-9\-]*[a-z0-9]|[a-z])|(?: \[[^\]]*\]))
                 * pathname=    (?:\/(?:[a-z0-9\-\._~\!\$\&\'\(\)\*\+\,\;\=\:\@]|%[0-9a-f]{2,2})*)*
                 * query=            (?:\?(?:[a-z0-9\-\._~\!\$\&\'\(\)\*\+\,\;\=\:\@\/\?]|%[0-9a-f]{2,2})*)?
                 * anchor=        (?:\#(?:[a-z0-9\-\._~\!\$\&\'\(\)\*\+\,\;\=\:\@\/\?]|%[0-9a-f]{2,2})*)?
                var regExp = /^(?:https?|ftp)\:\/\/(?:(?:[a-z0-9\-\._~\!\$\&\'\(\)\*\+\,\;\=:]|%[0-9a-f]{2,2})*\@)?(?: ((?:(?:[a-z0-9][a-z0-9\-]*[a-z0-9]|[a-z0-9])\.)*(?:[a-z][a-z0-9\-]*[a-z0-9]|[a-z])|(?:\[[^ \]]*\]))(?:\:[0-9]*)?)(?:\/(?:[a-z0-9\-\._~\!\$\&\'\(\)\*\+\,\;\=\:\@]|%[0-9a-f]{2,2})*)*( ?:\?(?:[a-z0-9\-\._~\!\$\&\'\(\)\*\+\,\;\=\:\@\/\?]|%[0-9a-f]{2,2})*)?(?:\#(?:[a-z0-9\-\._ ~\!\$\&\'\(\)\*\+\,\;\=\:\@\/\?]|%[0-9a-f]{2,2})*)?$/i;
                var valid = value.match(regExp);
                if (valid) {
                    //extract the  address from URL
                    var address = valid[1];
                    if (address) {
                        if (address == '[]') {
                            return false;
                        if (address.charAt(0) == '[' ) {
                            //IPv6 address or IPv4 enclosed in square brackets
                            address = address.replace(/^\[|\]$/gi, '');
                            return Spry.Widget.ValidationTextField.validateIP(address, 'ipv6_ipv4');
                        } else {
                            if (/[^0-9\.]/.test(address)) {
                                return true;
                            } else {
                                //check if hostname is all digits and dots and then check for IPv4
                                return Spry.Widget.ValidationTextField.validateIP(address, 'ipv4');
                    } else {
                        return true;
                } else {
                    return false;
    2.2.1. Preferred
    x:x:x:x:x:x:x:x, where the 'x's are the hexadecimal values of the eight 16-bit pieces of the address.
    Examples:
        FEDC:BA98:7654:3210:FEDC:BA98:7654:3210
        1080:0:0:0:8:800:200C:417A
    Note that it is not necessary to write the leading zeros in an
    individual field, but there must be at least one numeral in every
    field (except for the case described in 2.2.2.).
    2.2.2. Compressed
    The use of "::" indicates multiple groups of 16-bits of zeros.
    The "::" can only appear once in an address.  The "::" can also be
    used to compress the leading and/or trailing zeros in an address.
        1080:0:0:0:8:800:200C:417A --> 1080::8:800:200C:417A
        FF01:0:0:0:0:0:0:101 --> FF01::101
        0:0:0:0:0:0:0:1 --> ::1
        0:0:0:0:0:0:0:0 --> ::
    2.5.4 IPv6 Addresses with Embedded IPv4 Addresses
        IPv4-compatible IPv6 address (tunnel IPv6 packets over IPv4 routing infrastructures)
        ::0:129.144.52.38
        IPv4-mapped IPv6 address (represent the addresses of IPv4-only nodes as IPv6 addresses)
        ::ffff:129.144.52.38
    The text representation of IPv6 addresses and prefixes in Augmented BNF (Backus-Naur Form) [ABNF] for reference purposes.
    [ABNF http://tools.ietf.org/html/rfc2234]
          IPv6address = hexpart [ ":" IPv4address ]
          IPv4address = 1*3DIGIT "." 1*3DIGIT "." 1*3DIGIT "." 1*3DIGIT
          IPv6prefix  = hexpart "/" 1*2DIGIT
          hexpart = hexseq | hexseq "::" [ hexseq ] | "::" [ hexseq ]
          hexseq  = hex4 *( ":" hex4)
          hex4    = 1*4HEXDIG
    Spry.Widget.ValidationTextField.validateIP = function (value, format)
        var validIPv6Addresses = [
            //preferred
            /^(?:[a-f0-9]{1,4}:){7}[a-f0-9]{1,4}(?:\/\d{1,3})?$/i,
            //various compressed
            /^[a-f0-9]{0,4}::(?:\/\d{1,3})?$/i,
            /^:(?::[a-f0-9]{1,4}){1,6}(?:\/\d{1,3})?$/i,
            /^(?:[a-f0-9]{1,4}:){1,6}:(?:\/\d{1,3})?$/i,
            /^(?:[a-f0-9]{1,4}:)(?::[a-f0-9]{1,4}){1,6}(?:\/\d{1,3})?$/i,
            /^(?:[a-f0-9]{1,4}:){2}(?::[a-f0-9]{1,4}){1,5}(?:\/\d{1,3})?$/i,
            /^(?:[a-f0-9]{1,4}:){3}(?::[a-f0-9]{1,4}){1,4}(?:\/\d{1,3})?$/i,
            /^(?:[a-f0-9]{1,4}:){4}(?::[a-f0-9]{1,4}){1,3}(?:\/\d{1,3})?$/i,
            /^(?:[a-f0-9]{1,4}:){5}(?::[a-f0-9]{1,4}){1,2}(?:\/\d{1,3})?$/i,
            /^(?:[a-f0-9]{1,4}:){6}(?::[a-f0-9]{1,4})(?:\/\d{1,3})?$/i,
            //IPv6 mixes with IPv4
            /^(?:[a-f0-9]{1,4}:){6}(?:\d{1,3}\.){3}\d{1,3}(?:\/\d{1,3})?$/i,
            /^:(?::[a-f0-9]{1,4}){0,4}:(?:\d{1,3}\.){3}\d{1,3}(?:\/\d{1,3})?$/i,
            /^(?:[a-f0-9]{1,4}:){1,5}:(?:\d{1,3}\.){3}\d{1,3}(?:\/\d{1,3})?$/i,
            /^(?:[a-f0-9]{1,4}:)(?::[a-f0-9]{1,4}){1,4}:(?:\d{1,3}\.){3}\d{1,3}(?:\/\d{1,3})?$/i,
            /^(?:[a-f0-9]{1,4}:){2}(?::[a-f0-9]{1,4}){1,3}:(?:\d{1,3}\.){3}\d{1,3}(?:\/\d{1,3})?$/i,    
            /^(?:[a-f0-9]{1,4}:){3}(?::[a-f0-9]{1,4}){1,2}:(?:\d{1,3}\.){3}\d{1,3}(?:\/\d{1,3})?$/i,
            /^(?:[a-f0-9]{1,4}:){4}(?::[a-f0-9]{1,4}):(?:\d{1,3}\.){3}\d{1,3}(?:\/\d{1,3})?$/i
        var validIPv4Addresses = [
            //IPv4
            /^(\d{1,3}\.){3}\d{1,3}$/i
        var validAddresses = [];
        if (format == 'ipv6' || format == 'ipv6_ipv4') {
            validAddresses = validAddresses.concat(validIPv6Addresses);
        if (format == 'ipv4' || format == 'ipv6_ipv4') {
            validAddresses = validAddresses.concat(validIPv4Addresses);
        var ret = false;
        for (var i=0; i<validAddresses.length; i++) {
            if (validAddresses[i].test(value)) {
                ret = true;
                break;
        if (ret && value.indexOf(".") != -1) {
            //if address contains IPv4 fragment, it must be valid; all 4 groups must be less than 256
            var ipv4 = value.match(/:?(?:\d{1,3}\.){3}\d{1,3}/i);
            if(!ipv4) {
                return false;
            ipv4 = ipv4[0].replace(/^:/, '');
            var pieces = ipv4.split('.');
            if (pieces.length != 4) {
                return false;
            var regExp = /^[\-\+]?\d*$/;
            for (var i=0; i< pieces.length; i++) {
                if (pieces[i] == '') {
                    return false;
                var piece = parseInt(pieces[i], 10);
                if (isNaN(piece) || piece > 255 || !regExp.test(pieces[i]) || pieces[i].length>3 || /^0{2,3}$/.test(pieces[i])) {
                    return false;
        if (ret && value.indexOf("/") != -1) {
            // if prefix-length is specified must be in [1-128]
            var prefLen = value.match(/\/\d{1,3}$/);
            if (!prefLen) return false;
            var prefLenVal = parseInt(prefLen[0].replace(/^\//,''), 10);
            if (isNaN(prefLenVal) || prefLenVal > 128 || prefLenVal < 1) {
                return false;
        return ret;
    Spry.Widget.ValidationTextField.onloadDidFire = false;
    Spry.Widget.ValidationTextField.loadQueue = [];
    Spry.Widget.ValidationTextField.prototype.isBrowserSupported = function()
        return Spry.is.ie && Spry.is.v >= 5 && Spry.is.windows
            ||
        Spry.is.mozilla && Spry.is.v >= 1.4
            ||
        Spry.is.safari
            ||
        Spry.is.opera && Spry.is.v >= 9;
    Spry.Widget.ValidationTextField.prototype.init = function(element, options)
        this.element = this.getElement(element);
        this.errors = 0;
        this.flags = {locked: false, restoreSelection: true};
        this.options = {};
        this.event_handlers = [];
        this.validClass = "textfieldValidState";
        this.focusClass = "textfieldFocusState";
        this.requiredClass = "textfieldRequiredState";
        this.hintClass = "textfieldHintState";
        this.invalidFormatClass = "textfieldInvalidFormatState";
        this.invalidRangeMinClass = "textfieldMinValueState";
        this.invalidRangeMaxClass = "textfieldMaxValueState";
        this.invalidCharsMinClass = "textfieldMinCharsState";
        this.invalidCharsMaxClass = "textfieldMaxCharsState";
        this.textfieldFlashTextClass = "textfieldFlashText";
        if (Spry.is.safari) {
            this.flags.lastKeyPressedTimeStamp = 0;
        switch (this.type) {
            case 'phone_number':options.format = Spry.Widget.Utils.firstValid(options.format, 'phone_us');break;
            case 'currency':options.format = Spry.Widget.Utils.firstValid(options.format, 'comma_dot');break;
            case 'zip_code':options.format = Spry.Widget.Utils.firstValid(options.format, 'zip_us5');break;
            case 'date':
                options.format = Spry.Widget.Utils.firstValid(options.format, 'mm/dd/yy');
                break;
            case 'time':
                options.format = Spry.Widget.Utils.firstValid(options.format, 'HH:mm');
                options.pattern = options.format.replace(/[hms]/gi, "0").replace(/TT/gi, 'AM').replace(/T/gi, 'A');
                break;
            case 'ip':
                options.format = Spry.Widget.Utils.firstValid(options.format, 'ipv4');
                options.characterMasking = Spry.Widget.ValidationTextField.ValidationDescriptors[this.type].characterMaskingFormats[ options.format];
                break;
        //retrieve the validation type descriptor to be used with this instance (base on type and format)
        //widgets may have different validations depending on format (like zip_code with formats)
        var validationDescriptor = {};
        if (options.format && Spry.Widget.ValidationTextField.ValidationDescriptors[this.type].formats) {
            if (Spry.Widget.ValidationTextField.ValidationDescriptors[this.type].formats[options.format] ) {
                Spry.Widget.Utils.setOptions(validationDescriptor, Spry.Widget.ValidationTextField.ValidationDescriptors[this.type].formats[options.format]) ;
        } else {
            Spry.Widget.Utils.setOptions(validationDescriptor, Spry.Widget.ValidationTextField.ValidationDescriptors[this.type]);
        //set default values for some parameters which were not aspecified
        options.useCharacterMasking = Spry.Widget.Utils.firstValid(options.useCharacterMasking, false);
        options.hint = Spry.Widget.Utils.firstValid(options.hint, '');
        options.isRequired = Spry.Widget.Utils.firstValid(options.isRequired, true);
        options.additionalError = Spry.Widget.Utils.firstValid(options.additionalError, false);
        if (options.additionalError)
            options.additionalError = this.getElement(options.additionalError);
        //set widget validation parameters
        //get values from validation type descriptor
        //use the user specified values, if defined
        options.characterMasking = Spry.Widget.Utils.firstValid(options.characterMasking, validationDescriptor.characterMasking);
        options.regExpFilter = Spry.Widget.Utils.firstValid(options.regExpFilter, validationDescriptor.regExpFilter);
        options.pattern = Spry.Widget.Utils.firstValid(options.pattern, validationDescriptor.pattern);
        options.validation = Spry.Widget.Utils.firstValid(options.validation, validationDescriptor.validation);
        if (typeof options.validation == 'string') {
            options.validation = eval(options.validation);
        options.minValue = Spry.Widget.Utils.firstValid(options.minValue, validationDescriptor.minValue);
        options.maxValue = Spry.Widget.Utils.firstValid(options.maxValue, validationDescriptor.maxValue);
        options.minChars = Spry.Widget.Utils.firstValid(options.minChars, validationDescriptor.minChars);
        options.maxChars = Spry.Widget.Utils.firstValid(options.maxChars, validationDescriptor.maxChars);
        Spry.Widget.Utils.setOptions(this, options);
        Spry.Widget.Utils.setOptions(this.options, options);
    Spry.Widget.ValidationTextField.prototype.destroy = function() {
        if (this.event_handlers)
            for (var i=0; i<this.event_handlers.length; i++) {
                Spry.Widget.Utils.removeEventListener(this.event_handlers[i][0], this.event_handlers[i][1], this.event_handlers[i][2], false);
        try { delete this.element; } catch(err) {}
        try { delete this.input; } catch(err) {}
        try { delete this.form; } catch(err) {}
        try { delete this.event_handlers; } catch(err) {}
        try { this.selection.destroy(); } catch(err) {}
        try { delete this.selection; } catch(err) {}
        var q = Spry.Widget.Form.onSubmitWidgetQueue;
        var qlen = q.length;
        for (var i = 0; i < qlen; i++) {
            if (q[i] == this) {
                q.splice(i, 1);
                break;
    Spry.Widget.ValidationTextField.prototype.attachBehaviors = function()
        if (this.element) {
            if (this.element.nodeName == "INPUT") {
                this.input = this.element;
            } else {
                this.input = Spry.Widget.Utils.getFirstChildWithNodeNameAtAnyLevel(this.element, "INPUT");
        if (this.input) {
            if (this.maxChars) {
                this.input.removeAttribute("maxLength");
            this.putHint();
            this.compilePattern();
            if (this.type == 'date') {
                this.compileDatePattern();
            this.input.setAttribute("AutoComplete", "off");
            this.selection = new Spry.Widget.SelectionDescriptor(this.input);
            this.oldValue = this.input.value;
            var self = this;
            this.event_handlers = [];
            this.event_handlers.push([this.input, "keydown", function(e) { if (self.isDisabled()) return true; return self.onKeyDown(e || event); }]);
            this.event_handlers.push([this.input, "keypress", function(e) { if (self.isDisabled()) return true; return self.onKeyPress(e || event); }]);
            if (Spry.is.opera) {
                this.event_handlers.push([this.input, "keyup", function(e) { if (self.isDisabled()) return true; return self.onKeyUp(e || event); }]);
            this.event_handlers.push([this.input, "focus", function(e) { if (self.isDisabled()) return true; return self.onFocus(e || event); }]);
            this.event_handlers.push([this.input, "blur", function(e) { if (self.isDisabled()) return true; return self.onBlur(e || event); }]);
            this.event_handlers.push([this.input, "mousedown", function(e) { if (self.isDisabled()) return true; return self.onMouseDown(e || event); }]);
            var changeEvent =
                Spry.is.mozilla || Spry.is.opera || Spry.is.safari?"input":
                Spry.is.ie?"propertychange":
                "change";
            this.event_handlers.push([this.input, changeEvent, function(e) { if (self.isDisabled()) return true; return self.onChange(e || event); }]);
            if (Spry.is.mozilla || Spry.is.safari) {
                //oninput event on mozilla does not fire ondragdrop
                this.event_handlers.push([this.input, "dragdrop", function(e) { if (self.isDisabled()) return true; self.removeHint();return self.onChange(e || event); }]);
            } else if (Spry.is.ie){
                //ondrop&onpropertychange crash on IE
                this.event_handlers.push([this.input, "drop", function(e) { if (self.isDisabled()) return true; return self.onDrop(e || event); }]);
            for (var i=0; i<this.event_handlers.length; i++) {
                Spry.Widget.Utils.addEventListener(this.event_handlers[i][0], this.event_handlers[i][1], this.event_handlers[i][2], false);
            // submit
            this.form = Spry.Widget.Utils.getFirstParentWithNodeName(this.input, "FORM");
            if (this.form) {
                // if no "onSubmit" handler has been attached to the current form, attach one
                if (!this.form.attachedSubmitHandler && !this.form.onsubmit) {
                    this.form.onsubmit = function(e) { e = e || event; return Spry.Widget.Form.onSubmit(e, e.srcElement || e.currentTarget) };
                    this.form.attachedSubmitHandler = true;                
                if (!this.form.attachedResetHandler) {
                    Spry.Widget.Utils.addEventListener(this.form, "reset", function(e) { e = e || event; return Spry.Widget.Form.onReset(e, e.srcElement || e.currentTarget) }, false);
                    this.form.attachedResetHandler = true;                
                // add the currrent widget to the "onSubmit" check queue;
                Spry.Widget.Form.onSubmitWidgetQueue.push(this);
    Spry.Widget.ValidationTextField.prototype.isDisabled = function() {
        return this.input && (this.input.disabled || this.input.readOnly) || !this.input;
    Spry.Widget.ValidationTextField.prototype.getElement = function(ele)
        if (ele && typeof ele == "string")
            return document.getElementById(ele);
        return ele;
    Spry.Widget.ValidationTextField.addLoadListener = function(handler)
        if (typeof window.addEventListener != 'undefined')
            window.addEventListener('load', handler, false);
        else if (typeof document.addEventListener != 'undefined')
            document.addEventListener('load', handler, false);
        else if (typeof window.attachEvent != 'undefined')
            window.attachEvent('onload', handler);
    Spry.Widget.ValidationTextField.processLoadQueue = function(handler)
        Spry.Widget.ValidationTextField.onloadDidFire = true;
        var q = Spry.Widget.ValidationTextField.loadQueue;
        var qlen = q.length;
        for (var i = 0; i < qlen; i++)
            q[i].attachBehaviors();
    Spry.Widget.ValidationTextField.addLoadListener(Spry.Widget.ValidationTextField.processLoa dQueue);
    Spry.Widget.ValidationTextField.addLoadListener(function(){
        Spry.Widget.Utils.addEventListener(window, "unload", Spry.Widget.Form.destroyAll, false);
    Spry.Widget.ValidationTextField.prototype.setValue = function(newValue) {
        this.flags.locked = true;
        this.input.value = newValue;
        this.flags.locked = false;
        this.oldValue = newValue;
        if (!Spry.is.ie) {
            this.onChange();
    * save the state of the input (selection and value) so we can revert to it
    * should call this just before modifying the input value
    Spry.Widget.ValidationTextField.prototype.saveState = function()
        this.oldValue = this.input.value;
        this.selection.update();
    Spry.Widget.ValidationTextField.prototype.revertState = function(revertValue)
        if (revertValue != this.input.value) {
            this.input.readOnly = true;
            this.input.value = revertValue;
            this.input.readOnly = false;
            if (Spry.is.safari && this.flags.active) {
                this.input.focus();
      if (this.flags.restoreSelection) {
        this.selection.moveTo(this.selection.start, this.selection.end);
        this.redTextFlash();
    Spry.Widget.ValidationTextField.prototype.removeHint = function()
        if (this.flags.hintOn) {
            this.input.value = "";
            this.flags.hintOn = false;
            this.removeClassName(this.element, this.hintClass);
            this.removeClassName(this.additionalError, this.hintClass);
    Spry.Widget.ValidationTextField.prototype.putHint = function()
        if(this.hint && this.input && this.input.type == "text" && this.input.value == "") {
            this.flags.hintOn = true;
            this.input.value = this.hint;
            this.addClassName(this.element, this.hintClass);
            this.addClassName(this.additionalError, this.hintClass);
    Spry.Widget.ValidationTextField.prototype.redTextFlash = function()
        var self = this;
        this.addClassName(this.element, this.textfieldFlashTextClass);
        setTimeout(function() {
            self.removeClassName(self.element, self.textfieldFlashTextClass)
        }, 100);
    Spry.Widget.ValidationTextField.prototype.doValidations = function(testValue, revertValue)
        if (this.isDisabled()) return false;
        if (this.flags.locked) {
            return false;
        if (testValue.length == 0 && !this.isRequired) {
            this.errors = 0;
            return false;
        this.flags.locked = true;
        var mustRevert = false;
        var continueValidations = true;
        if (!this.options.isRequired && testValue.length == 0) {
            continueValidations = false;
        var errors = 0;
        var fixedValue = testValue;
        //characterMasking - test if all characters are valid with the characterMasking (keyboard filter)
        if (this.useCharacterMasking && this.characterMasking) {
            for(var i=0; i<testValue.length; i++) {
                if (!this.characterMasking.test(testValue.charAt(i))) {
                    errors = errors | Spry.Widget.ValidationTextField.ERROR_FORMAT;
                    fixedValue = revertValue;
                    mustRevert = true;
                    break;
        //regExpFilter - character mask positioning (additional mask to restrict some characters only in some position)
        if (!mustRevert && this.useCharacterMasking && this.regExpFilter) {
            if (!this.regExpFilter.test(fixedValue)) {
                errors = errors | Spry.Widget.ValidationTextField.ERROR_FORMAT;
                mustRevert = true;
        //pattern - testValue matches the pattern so far
        if (!mustRevert && this.pattern) {
            var currentRegExp = this.patternToRegExp(testValue.length);
            if (!currentRegExp.test(testValue)) {
                errors = errors | Spry.Widget.ValidationTextField.ERROR_FORMAT;
                mustRevert = true;
            } else if (this.patternLength != testValue.length) {
                //testValue matches pattern so far, but it's not ok if it does not have the proper length
                //do not revert, but should show the error
                errors = errors | Spry.Widget.ValidationTextField.ERROR_FORMAT;
        if (fixedValue == '') {
            errors = errors | Spry.Widget.ValidationTextField.ERROR_REQUIRED;
        if (!mustRevert && this.pattern && this.useCharacterMasking) {
            var n = this.getAutoComplete(testValue.length);
            if (n) {
                fixedValue += n;
        if(!mustRevert && this.minChars !== null  && continueValidations) {
            if (testValue.length < this.minChars) {
                errors = errors | Spry.Widget.ValidationTextField.ERROR_CHARS_MIN;
                continueValidations = false;
        if(!mustRevert && this.maxChars !== null && continueValidations) {
            if (testValue.length > this.maxChars) {
                errors = errors | Spry.Widget.ValidationTextField.ERROR_CHARS_MAX;
                continueValidations = false;
        //validation - testValue passes widget validation function
        if (!mustRevert && this.validation && continueValidations) {
            var value = this.validation(fixedValue, this.options);
            if (false === value) {
                errors = errors | Spry.Widget.ValidationTextField.ERROR_FORMAT;
                continueValidations = false;
            } else {
                this.typedValue = value;
        if(!mustRevert && this.validation && this.minValue !== null && continueValidations) {
            var minValue = this.validation(this.minValue.toString(), this.options);
            if (minValue !== false) {
                if (this.typedValue < minValue) {
                    errors = errors | Spry.Widget.ValidationTextField.ERROR_RANGE_MIN;
                    continueValidations = false;
        if(!mustRevert && this.validation && this.maxValue !== null && continueValidations) {
            var maxValue = this.validation(this.maxValue.toString(), this.options);
            if (maxValue !== false) {
                if( this.typedValue > maxValue) {
                    errors = errors | Spry.Widget.ValidationTextField.ERROR_RANGE_MAX;
                    continueValidations = false;
        //an invalid value was tested; must make sure it does not get inside the input
        if (this.useCharacterMasking && mustRevert) {
            this.revertState(revertValue);
        this.errors = errors;
        this.fixedValue = fixedValue;
        this.flags.locked = false;
        return mustRevert;
    Spry.Widget.ValidationTextField.prototype.onChange = function(e)
        if (Spry.is.opera && this.flags.operaRevertOnKeyUp) {
            return true;
        if (Spry.is.ie && e && e.propertyName != 'value') {
            return true;

  • Struts and validation question ?

    hi,
    i am using the struts framework for my application, i have a simple jsp logon page (username, password)
    i have defined a validtion.xml file
    <?xml version="1.0" encoding="ISO-8859-1" ?>
    <!DOCTYPE form-validation PUBLIC
              "-//Apache Software Foundation//DTD Commons Validator Rules Configuration 1.0//EN"
              "http://jakarta.apache.org/commons/dtds/validator_1_0.dtd">
    <!--
        Validation Rules for the Struts Example Web Application
        $Id: validation.xml,v 1.8 2003/05/25 22:51:20 dgraham Exp $
    -->
    <form-validation>
        <!-- ========== Default Language Form Definitions ===================== -->
        <formset>
            <form name="logonForm">
                <field property="username"
                        depends="required, minlength,maxlength">
                    <arg0   key="prompt.username"/>
                    <arg1   key="${var:minlength}" name="minlength"
                       resource="false"/>
                    <arg2   key="${var:maxlength}" name="maxlength"
                       resource="false"/>
                    <var>
                        <var-name>maxlength</var-name>
                        <var-value>16</var-value>
                    </var>
                    <var>
                        <var-name>minlength</var-name>
                        <var-value>3</var-value>
                    </var>
                </field>
                <field property="password"
                        depends="required, minlength,maxlength">
                    <arg0   key="prompt.password"/>
                    <arg1   key="${var:minlength}" name="minlength"
                       resource="false"/>
                    <arg2   key="${var:maxlength}" name="maxlength"
                       resource="false"/>
                    <var>
                        <var-name>maxlength</var-name>
                        <var-value>16</var-value>
                    </var>
                    <var>
                        <var-name>minlength</var-name>
                        <var-value>3</var-value>
                    </var>
                </field>
            </form>
            <form name="registrationForm">
                <field property="fromAddress"
                        depends="required,email">
                    <arg0   key="prompt.fromAddress"/>
                </field>
                <field property="fullName"
                        depends="required">
                  <arg0     key="prompt.fullName"/>
                </field>
                <field property="replyToAddress"
                        depends="email">
                    <arg0   key="prompt.replyToAddress"/>
                </field>
                <field property="username"
                        depends="required">
                  <arg0     key="prompt.username"/>
                </field>
            </form>
        </formset>
    </form-validation>i have also the validation-rules.xml file provided by the struts lib.
    i would like to force the content of 'username' property to be alphabetic.
    i guess i have to create my own element
    <validator name="alphabeticString"...> inside the validation-rules.xml file, but i am newbie in javascript programming.
    i have tree question.
    1) why the validation code inside the validator element is written in javascript since it's not going to be executed at client side???
    2)can i use java instead ? (to code teh validation ...)
    3)has anyone got a code to solve this problem ?
    thanks for your help

    i would like to force the content of 'username' property to be alphabetic.
    i guess i have to create my own element
    <validator name="alphabeticString"...> inside the validation-rules.xml file,
    but i am newbie in javascript programming.Not for something that simple... there's a validator rule called mask, which takes a regular expression as an argument, so if you want only a-z: "[a-zA-Z]*" should work.
    1) why the validation code inside the validator element is written in javascript since it's not going to be executed at client side???It is validated on the client, or can be. You have to include the javascript with the html:javascript tag library tag and specify the form name. Then you need to put the onsubmit="return validateFormName();" attribute in the form tag. If JS isn't supported, it'll still default back to the server side validation.
    2)can i use java instead ? (to code teh validation ...)Don't include the JS stuff.

  • PHP email form with Validation - not working

    Hello;
    I am new to using php. I usually use coldfusion or asp but this site requires me to write in php. I have a form I am trying to get to work and right now.. it doesn't do anyhting but remember what you put in the fields. It doesn't want to send, and it won't execute the validation script for the fields that are required. Can anyone help me make this work? I'm confused and a definate newbie to PHP.
    Here is my code:
    <?php    
                  $PHP_SELF = $_SERVER['PHP_SELF'];   
                  $errName    = "";   
                  $errEmail    = "";
                  $errPhone    = "";        
                  if(isset($_POST['submit'])) {        
                          if($_POST["ac"]=="login"){            
                        $FORMOK = TRUE;    // $FORMOK acts as a flag. If you enter any of the conditionals below,                             // it gets set to FALSE, and the e-mail will not be sent.
                        // First Name           
                        if(preg_match("/^[a-zA-Z -]+$/", $_POST["name"]) === 0) {               
                            $errName = '<div class="errtext">Please enter you name.</div>';               
                            $FORMOK = FALSE;           
                        // Email           
                    if(preg_match("/^[a-zA-Z]\w+(\.\w+)*\@\w+(\.[0-9a-zA-Z]+)*\.[a-zA-Z]{2,4}$/", $_POST["email"]) === 0) {                                                    $errEmail = '<div class="errtext">Please enter a valid email.</div>';               
                            $FORMOK = FALSE;           
                        // Phone           
                        if(preg_match("/^[a-zA-Z -]+$/", $_POST["phone"]) === 0) {               
                            $errPhone = '<div class="errtext">Please enter your phone number.</div>';               
                            $FORMOK = FALSE;           
                        if($FORMOK) {               
                                $to = "[email protected]";  
                                $subject = "my. - Contact Form";                  
                                $name_field = $_POST['name'];               
                                $email_field = $_POST['email'];               
                                $phone_field = $_POST['phone'];
                                $city_field = $_POST['city'];
                                $state_field = $_POST['state'];               
                                $message = $_POST['comment'];                
                                $message = "               
                                Name: $name_field               
                                Email: $email_field
                                Phone: $phone_field   
                                City: $city_field   
                                State: $state_field               
                                Message: $message";                
                                $headers  = 'MIME-Version: 1.0' . "\r\n";               
                                $headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";                
                                // Additional headers               
                                $headers .= 'To: <[email protected]>' . "\r\n";               
                                $headers .= '[From] <$email_field>' . "\r\n";                
                                // Mail it               
                                mail($to, $subject, $message, $headers);                
                                header("Location: thankyou.php")
                                // I have no idea what these next 3 lines are for. You may just want to get rid of them.                   
    ini_set("sendmail_from","[Send from]");
    ini_set("SMTP","[mail server]");
    mail($to, $subject, $message, $headers);
                                } else {               
                                echo "Error!";              
                        ?>
    <form method="post" action="<?php $PHP_SELF ?>" id="commentForm">
    <input name="name" size="40" value="<?php echo $_POST["name"]; ?>" type="text">
                         <?php  if(isset($errName)) echo $errName; ?>
    <input name="email" size="40" value="<?php echo $_POST["email"]; ?>"  type="text">
            <?php  if(isset($errEmail)) echo $errEmail; ?>
    <input name="phone" size="40" value="<?php echo $_POST["phone"]; ?>" type="text" id="phone">
            <?php  if(isset($errPhone)) echo $errPhone; ?>
    <input name="city" size="40" value="<?php echo $_POST["city"]; ?>" type="text" id="city">
    <input name="state" size="40" value="<?php echo $_POST["state"]; ?>" type="text" id="state">
    <textarea name="comment" cols="30" rows="10" id="comment"><?php echo $_POST["comment"]; ?></textarea>
    <input type="submit" value="Submit" name="submit" class="contact-submit" />
    </form>
    It seems pretty simple.. but it's not working at all. I would also like this page to submit to it's self, and when it actually does send an email, to just make the form disappear and replace it with the thank you text instead of sending you to another page. I also do not need to use an smtp server, it goes directly to the network server when sent.
    I'm really sorry to ask all of this, I'm trying to learn this language and need to make this work.
    Thank you for anyones help in advance.

    .oO(BarryGBrown)
    > I have a php file which generates an email from a form
    in a website I have
    >designed. I just want to make some areas of the final
    generated email in bold
    >text. I know if people have plain text only selected in
    their email client they
    >won't see the bold text, but at least it will reach a
    certain percentage of
    >users.
    You can't do bold text in a normal email. Plain text is just
    that -
    plain text. For anything more you need HTML. _If_ you should
    need it.
    Usually plain text serves pretty well and is the most
    efficient way.
    > the line in question is -
    >
    > $body ="Booking request details from website:\n\n";
    >
    > I have tried putting  and ,
    syntax is used in some forum software, but besides that it
    has
    no meaning whatsoever.
    >inside the inverted commas, outside
    >etc, plus tried different declarations within the
    <head>, nothing works! What
    >am I doing wrong?
    You would have to create an entire HTML email with all the
    required
    headers and boundaries. Quite difficult to do by hand with
    PHP's mail()
    function.
    > I am a beginner with this php stuff, please be kind!
    Then you should start simple with plain text. There are some
    classes out
    there which make it easy to generate text and HTML emails
    (phpmailer for
    example), but you should be familiar with PHP coding if you
    want to use
    them.
    Micha

  • Validator Question

    Hi i am creating an application where a user simply enters their details such as name, email etc which should be then validated using the validator. If the details are correct it should redirect the user to my Acknowledge page, however if not it will put the user back to the original part displaying error messages to re-enter their details. Now as it stands i already have the a form for the user to enter their details, enterStudentDetails.jsp, and i am trying to test that their email is not left blank but when i do leave it blank, and hit the submit button, it goes into my Acknowledge.jsp page. That is the issue i have at the moment, and i am trying use the validator to check the input on the server side to display the error message.
    enterStudentDetails.jsp
    <%@ taglib uri="http://jakarta.apache.org/struts/tags-bean" prefix="bean" %>
    <%@ taglib uri="http://jakarta.apache.org/struts/tags-html" prefix="html" %>
    <%@page contentType="text/html"%>
    <%@page pageEncoding="UTF-8"%>
    <%--
    The taglib directive below imports the JSTL library. If you uncomment it,
    you must also add the JSTL library to the project. The Add Library... action
    on Libraries node in Projects view can be used to add the JSTL 1.1 library.
    --%>
    <%--
    <%@taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
    --%>
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
       "http://www.w3.org/TR/html4/loose.dtd">
    <html>
        <head>
            <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
            <title>Enter Student Details</title>
        </head>
        <body>
        <h1>Enter Student Details</h1>
        <html:form action="ValidateDetails">
            <table border="1">
                <thead>
                    <tr>
                        <td>Email :
                        <td><bean:message key="validatedetails.email" />
                        <th> <html:text property="email" size="32"/>
                        <th><html:errors property="email" />
                    </tr>
                </thead>
                <tbody>
                    <tr>
                        <td>First Name:</td>
                         <td><bean:message key="validatedetails.firstName" />
                        <td><html:text property="firstName"/></td>
                        <td><html:errors property="firstName"/></td>
                    </tr>
                    <tr>
                        <td>Last Name: </td>
                         <td><bean:message key="validatedetails.lastName" />
                        <td><html:text property="lastName"/></td>
                        <td><html:errors property="lastName"/></td>
                    </tr>
                    <tr>
                        <td> Password
                         <td><bean:message key="validatedetails.password" />
                        <td><html:password property="password"/></td>
                        <td><html:errors property="password"/></td>
                    </tr>
                    <tr>
                        <td> Confirm Password
                         <td><bean:message key="validatedetails.confirmPassword" />
                        <td><html:password property="confirmPassword"/></td>
                        <td><html:errors property="confirmPassword"/></td>
                    </tr>
                    <tr>
                        <td>Date of birth (dd/mm/yyyy):
                        <td><html:text property="dateOfBirth"/></td>
                        <td><html:errors property="dateOfBirth"/></td>
                    </tr>
                    <td><html:submit value="sign up!" />
                </tbody>
            </table>   
        </html:form>
        <%--
        This example uses JSTL, uncomment the taglib directive above.
        To test, display the page like this: index.jsp?sayHello=true&name=Murphy
        --%>
        <%--
        <c:if test="${param.sayHello}">
            <!-- Let's welcome the user ${param.name} -->
            Hello ${param.name}!
        </c:if>
        --%>
        </body>
    </html>ValidateDetails.java
    * ValidateDetails.java
    * Created on 10 April 2008, 22:00
    package com.myapp.struts;
    import javax.servlet.http.HttpServletRequest;
    import javax.servlet.http.HttpServletResponse;
    import org.apache.struts.action.Action;
    import org.apache.struts.action.ActionForm;
    import org.apache.struts.action.ActionMapping;
    import org.apache.struts.action.ActionForward;
    * @author
    * @version
    public class ValidateDetails extends Action {
        /* forward name="success" path="" */
        private final static String SUCCESS = "success";
         * This is the action called from the Struts framework.
         * @param mapping The ActionMapping used to select this instance.
         * @param form The optional ActionForm bean for this request.
         * @param request The HTTP Request we are processing.
         * @param response The HTTP Response we are processing.
         * @throws java.lang.Exception
         * @return
        public ActionForward execute(ActionMapping mapping, ActionForm  form,
                HttpServletRequest request, HttpServletResponse response)
                throws Exception {
            return mapping.findForward(SUCCESS);
    }DetailsForm.java
    * DetailsForm.java
    * Created on 10 April 2008, 21:52
    package com.myapp.struts;
    import javax.servlet.http.HttpServletRequest;
    import org.apache.struts.action.ActionErrors;
    import org.apache.struts.action.ActionMapping;
    import org.apache.struts.action.ActionMessage;
    import java.text.ParseException;
    import java.text.SimpleDateFormat;
    import java.util.Date;
    * @author
    * @version
    public class DetailsForm extends org.apache.struts.validator.ValidatorForm {
       private int id;
        private String firstName;
        private String lastName;
        private String password;
        private String confirmPassword;
        private String email;
        private Date dateOfBirth;
        public int getId() {
            return id;
        public String getFirstName() {
            return firstName;
        public String getLastName() {
            return lastName;
        public String getPassword() {
            return password;
        public String getEmail() {
            return email;
        public Date getDateOfBirth() {
            return dateOfBirth;
        public String getConfirmPassword() {
            return confirmPassword;
        public void setFirstName(String s) {
            firstName = s;
        public void setLastName(String s) {
            lastName = s;
        public void setPassword(String s) {
            password = s;
        public void setEmail(String s) {
            email = s;
        public void setDateOfBirth(String s) {
            try {
                // TODO: put the date format in the resources file
                dateOfBirth = new SimpleDateFormat("dd/MM/yyyy").parse(s);
            } catch (ParseException e) {
        public void setConfirmPassword(String s) {
           confirmPassword = s;
           password = confirmPassword;
        public DetailsForm() {
            super();
            // TODO Auto-generated constructor stub
    /**  public ActionErrors validate(ActionMapping mapping, HttpServletRequest request) {
            ActionErrors errors = new ActionErrors();
            if (getName() == null || getName().length() < 1) {
                errors.add("name", new ActionMessage("error.name.required"));
                // TODO: add 'error.name.required' key to your resources
            return errors;
       */struts-config.xml
    <?xml version="1.0" encoding="UTF-8" ?>
    <!DOCTYPE struts-config PUBLIC
    "-//Apache Software Foundation//DTD Struts Configuration 1.2//EN"
    "http://jakarta.apache.org/struts/dtds/struts-config_1_2.dtd">
    <struts-config>
        <form-beans>
            <form-bean name="DetailsForm" type="com.myapp.struts.DetailsForm"/>
        </form-beans>
        <global-exceptions>
        </global-exceptions>
        <global-forwards>
            <forward name="welcome"  path="/Welcome.do"/>
        </global-forwards>
        <action-mappings>
            <action input="/enterStudentDetails.jsp"
                    validate="true"
                    name="DetailsForm"
                    path="/ValidateDetails"
                    scope="request"
                    type="com.myapp.struts.ValidateDetails">
                <forward name="success" path="/Acknowledge.jsp"/>
            </action>
            <action path="/Welcome" forward="/welcomeStruts.jsp"/>
        </action-mappings>
        <controller processorClass="org.apache.struts.tiles.TilesRequestProcessor"/>
        <message-resources parameter="com/myapp/struts/ApplicationResource"/>   
        <!-- ========================= Tiles plugin ===============================-->
        <!--
        This plugin initialize Tiles definition factory. This later can takes some
        parameters explained here after. The plugin first read parameters from
        web.xml, thenoverload them with parameters defined here. All parameters
        are optional.
        The plugin should be declared in each struts-config file.
        - definitions-config: (optional)
        Specify configuration file names. There can be several comma
        separated file names (default: ?? )
        - moduleAware: (optional - struts1.1)
        Specify if the Tiles definition factory is module aware. If true
        (default), there will be one factory for each Struts module.
        If false, there will be one common factory for all module. In this
        later case, it is still needed to declare one plugin per module.
        The factory will be initialized with parameters found in the first
        initialized plugin (generally the one associated with the default
        module).
        true : One factory per module. (default)
        false : one single shared factory for all modules
        - definitions-parser-validate: (optional)
        Specify if xml parser should validate the Tiles configuration file.
        true : validate. DTD should be specified in file header (default)
        false : no validation
        Paths found in Tiles definitions are relative to the main context.
        -->
        <plug-in className="org.apache.struts.tiles.TilesPlugin" >
            <set-property property="definitions-config" value="/WEB-INF/tiles-defs.xml" />     
            <set-property property="moduleAware" value="true" />
        </plug-in>
        <!-- ========================= Validator plugin ================================= -->
        <plug-in className="org.apache.struts.validator.ValidatorPlugIn">
            <set-property
                property="pathnames"
                value="/WEB-INF/validator-rules.xml,/WEB-INF/validation.xml"/>
        </plug-in>
    </struts-config>Application Resource file
    errors.header=
    errors.prefix=<span style="color: red">
    errors.suffix=</span>
    errors.footer=
    DetailsForm.required.email=Email must be entered
    validatedetails.email=Email
    validatedetails.firstName=First Name
    validatedetails.lastName=Last Name
    validatedetails.password=Password
    validatedetails.confirmPassword=Confirm Password
    error.email.required=Email must be entered
    errors.header=<UL>
    errors.prefix=<LI>
    errors.suffix=</LI>
    errors.footer=</UL>
    errors.invalid={0} is invalid.
    errors.maxlength={0} can not be greater than {1} characters.
    errors.minlength={0} can not be less than {1} characters.
    errors.range={0} is not in the range {1} through {2}.
    errors.required={0} is required.
    errors.byte={0} must be an byte.
    errors.date={0} is not a date.
    errors.double={0} must be an double.
    errors.float={0} must be an float.
    errors.integer={0} must be an integer.
    errors.long={0} must be an long.
    errors.short={0} must be an short.
    errors.creditcard={0} is not a valid credit card number.
    errors.email={0} is an invalid e-mail address.
    errors.cancel=Operation cancelled.
    errors.detail={0}
    errors.general=The process did not complete. Details should follow.
    errors.token=Request could not be completed. Operation is not in sequence.
    welcome.title=Struts Application
    welcome.heading=Struts Applications in Netbeans!
    welcome.message=It's easy to create Struts applications with NetBeans.validation.xml
    <?xml version="1.0" encoding="UTF-8" ?>
    <!DOCTYPE form-validation PUBLIC
    "-//Apache Software Foundation//DTD Commons Validator Rules Configuration 1.1.3//EN"
    "http://jakarta.apache.org/commons/dtds/validator_1_1_3.dtd">
    <form-validation>
        <form name="DetailsForm">
            <field
                property="email"
                depends="required,email">
                <arg key="DetailsForm.email"/>
            </field>
            <field
                property="firstName"
                depends="required">
                <arg key="error.firstName" />
            </field>
            <field
                property="lastName"
                depends="required">
                <arg key="error.lastName" />
            </field>
            <field
                property="password"
                depends="required,minlength">
                <arg key="error.password" />
                <arg1 name="minlength" key="${var:minlength}" resource="false" />
                <var>
                    <var-name>minlength</var-name>
                    <var-value>6</var-value>
                </var>
            </field>
            <field
                property="confirmPassword"
                depends="required,validwhen">
                <arg key="error.password" />
                <msg name="validwhen" key="error.password.confirm" />
                <var>
                    <var-name> test </var-name>
                    <var-value> (*this* == password) </var-value>
                </var>
            </field>
            <field
                property="dateOfBirth"
                depends="required,date">
                <arg key="Date of Birth" resource="false" />
                <var>
                    <var-name>datePatternStrict</var-name>
                    <var-value>dd/mm/yyyy</var-value>
                </var>
            </field>
        </form>
        <!--
         This is a minimal Validator form file with a couple of examples.
    -->
        <global>
            <!-- An example global constant
            <constant>
                <constant-name>postalCode</constant-name>
                <constant-value>^\d{5}\d*$</constant-value>
            </constant>
            end example-->
        </global>
        <formset>
            <!-- An example form -->
            <form name="logonForm">
                <field
                    property="username"
                    depends="required">
                    <arg key="logonForm.username"/>
                </field>
                <field
                    property="password"
                    depends="required,mask">
                    <arg key="logonForm.password"/>
                    <var>
                        <var-name>mask</var-name>
                        <var-value>^[0-9a-zA-Z]*$</var-value>
                    </var>
                </field>
            </form>
        </formset>
        <!-- An example formset for another locale -->
        <formset language="fr">
            <constant>
                <constant-name>postalCode</constant-name>
                <constant-value>^[0-9a-zA-Z]*$</constant-value>
            </constant>
            <!-- An example form -->
            <form name="logonForm">
                <field
                    property="username"
                    depends="required">
                    <arg key="logonForm.username"/>
                </field>
                <field
                    property="password"
                    depends="required,mask">
                    <arg key="logonForm.password"/>
                    <var>
                        <var-name>mask</var-name>
                        <var-value>^[0-9a-zA-Z]*$</var-value>
                    </var>
                </field>
            </form>
        </formset>
    </form-validation>Now, i have read a few articles on the subject but i am slighly confused in that in terms of creating a bean does it necessarily nead to be a dynamic bean? or can i still keep the one that i have right now for me to use validator. Can somebody provide some insight on what i would need to do because i am slighly confused.
    Thanks.

    oh, i didn't realize i could do that. I acutally already
    found a way to do it, if a whole bunch of if statments :) mhehe,
    but it works. i'lll try to do it your way :)
    another question. It seems that in my functions if i
    reference a field which is located on a different tab, it does not
    recoglize it, and i get a runtime error, unless i click on that
    tab, before clicking on the "validate" button.
    does anyone know why it's not recognizing it? do i need to
    somehow declare that field in my init()?
    Thanks!

  • Forms and validations - here's some of my ideas, what are yours?

    One of the big things still missing from the JFX space (especially where JEE is concerned) is forms and form validations. Maybe you guys have been luckier but at least 80% of the screens I've had to build in my career have been boring old forms - enter data in the fields, validate them and hit submit.
    So, I've been hacking around on this to try and get a pattern and hopefully some reusable classes for doing this in JavaFX. I have something that works but the code is verbose and less than elegant. I'm hoping some of you guys might want to kick around some ideas on this with me here. If we can come up with something that works, I'd like to either include it in [url http://www.zenjava.com/jfx-flow/]JFX Flow, or put it out as a separate open source project (whichever makes more sense).
    What I think needs to be supported:
    * Map between a normal Java bean and the fields on a form
    * Validate the data, i.e. specifying the constraints on a field and then checking those constraints
    * Show a validation summary at the top of the form
    * Highlight individual fields if they have validation errors
    * Support auto-validation, i.e. the validation highlights and messages will instantly update as the user types
    Some extra restrictions:
    * The data input will ideally be a normal bean and so it won't have observable values on it. In most projects I use, the beans are coming from the server and sometimes may be shared between desktop client and a jsp/web client, or even be a third party API so they can't be changed. End result: we don't want any JFX complexities or dependencies in our server code (design leak). This rule could be bent but only as a last resort.
    * The validations must be defined relative to the normal data bean not a JFX model or controller, etc. This is so the bean can be validated on the server as well as the client. The server must do validation to prevent dodgy data getting in (never trust a client). Ideally we don't want to be specifying the validations in two places (i.e. once for the client and once for the server) as this creates maintenance problems and weakens the integrity of the system over time.
    * Ideally the validation mechanism will be based on [url http://java.dzone.com/articles/bean-validation-and-jsr-303]JSR 303 - Bean Validations as this is quite nice. This is flexible however if there is a suitable alternative that integrates better.
    To give us something to reference in conversation, I've created a small working sample. This is only meant to be a rough starting point (at best) and I'd really like to get feedback on both the code (i.e. should we have a 'presentation model', how could bindings be better used, etc) and the general way I'm representing errors (i.e. should we use tooltips to show errors, or actually show the errors next to the field, should we use border colours or put a little exclamation mark over the field, should the fields be auto-validated or only validated on submit, etc).
    The example is a single form for editing a person. It has three fields, first name, last name and gender. When the form is blank, auto-editing is off. When the user submits the form it is validated and from that point on auto-validating is on. Error fields are highlighted with a style change, and a tooltip is added with details (I think we can do better - what's your ideas?).
    I have used all plain Java to keep thngs simple, but I'd be looking for the end result to translate to FXML as well. I've also coded everything into the one class but the eventual goal would be to have the common stuff moved out to reusable base classes, etc.
    Here's a workspace with some example code in it: http://code.google.com/p/jfxee/source/browse/trunk/jfxforms/
    Here's a running deploy of that code: http://zenjava.com/demo/form/forms.html
    (edit: I've moved the code to its own project and changed the url for the launch - the values above are the new, correct ones)
    Looking forward to hearing some thoughts on this topic.
    Edited by: zonski on 01-Dec-2011 13:41

    At Devoxx I did some straw man prototype that you might find useful (or hopeless, I'm not sure which, I did it in a hurry :-)). I followed some principles that I was influenced by years back by JGoodies, but I haven't looked at the JGoodies stuff in forever and know it isn't all the same. But anyway, like I said, I'm not sure it is actually useful but maybe there is something genius hidden in there.
    I have a Validator, which is just a simple SAM:
    import javafx.scene.control.Control;
    * @author Richard
    public interface Validator<C extends Control> {
        public ValidationResult validate(C control);
    }The idea is that it is given a Control, it will validate that control, and then return a ValidationResult. ValidationResult is actually only needed in cases of errors, since returning null indicates success, so the following is somewhat of a crock but you could rename it ValidationError or something and remove the "SUCCESS" type and there you are.
    public class ValidationResult {
        public enum Type { ERROR, WARNING, SUCCESS }
        private final String message;
        private final Type type;
        public ValidationResult(String message, Type type) {
            this.message = message;
            this.type = type;
        public final String getMessage() {
            return message;
        public final Type getType() {
            return type;
        }For good measure I threw in a ValidationEvent.
    import javafx.event.Event;
    import javafx.event.EventType;
    * @author Richard
    public class ValidationEvent extends Event {
        public static final EventType<ValidationEvent> ANY =
                new EventType<ValidationEvent>(Event.ANY, "VALIDATION");
        private final ValidationResult result;
        public ValidationEvent(ValidationResult result) {
            super(ANY);
            this.result = result;
        public final ValidationResult getResult() { return result; }
    }Because Control's don't presently have the notion of validation built in, I created a ValidationPane which is like a specialized StackPane, where there is a bottom layer, the control, and a glass pane layer. And from CSS you can style it however you like. The ValidationPane has a CSS style class set in case of errors / warnings. So without augmenting controls, the idea is that a ValidationPane subclass would exist to wrap each type of control you needed to validate. It did this because somebody has to wire up the listeners to the control to react on text input etc, and so I thought I'd like that encapsulated in something reusable, and there it was.
    import javafx.beans.DefaultProperty;
    import javafx.beans.property.ObjectProperty;
    import javafx.beans.property.ReadOnlyObjectProperty;
    import javafx.beans.property.ReadOnlyObjectWrapper;
    import javafx.beans.property.SimpleObjectProperty;
    import javafx.beans.value.ChangeListener;
    import javafx.beans.value.ObservableValue;
    import javafx.event.EventHandler;
    import javafx.scene.control.Control;
    import javafx.scene.layout.Region;
    * @author Richard
    @DefaultProperty("content")
    public abstract class ValidatorPane<C extends Control> extends Region {
         * The content for the validator pane is the control it should work with.
        private ObjectProperty<C> content = new SimpleObjectProperty<C>(this, "content", null);
        public final C getContent() { return content.get(); }
        public final void setContent(C value) { content.set(value); }
        public final ObjectProperty<C> contentProperty() { return content; }
         * The validator
        private ObjectProperty<Validator<C>> validator = new SimpleObjectProperty<Validator<C>>(this, "validator");
        public final Validator<C> getValidator() { return validator.get(); }
        public final void setValidator(Validator<C> value) { validator.set(value); }
        public final ObjectProperty<Validator<C>> validatorProperty() { return validator; }
         * The validation result
        private ReadOnlyObjectWrapper<ValidationResult> validationResult = new ReadOnlyObjectWrapper<ValidationResult>(this, "validationResult");
        public final ValidationResult getValidationResult() { return validationResult.get(); }
        public final ReadOnlyObjectProperty<ValidationResult> validationResultProperty() { return validationResult.getReadOnlyProperty(); }
         *  The event handler
        private ObjectProperty<EventHandler<ValidationEvent>> onValidation =
                new SimpleObjectProperty<EventHandler<ValidationEvent>>(this, "onValidation");
        public final EventHandler<ValidationEvent> getOnValidation() { return onValidation.get(); }
        public final void setOnValidation(EventHandler<ValidationEvent> value) { onValidation.set(value); }
        public final ObjectProperty<EventHandler<ValidationEvent>> onValidationProperty() { return onValidation; }
        public ValidatorPane() {
            content.addListener(new ChangeListener<Control>() {
                public void changed(ObservableValue<? extends Control> ov, Control oldValue, Control newValue) {
                    if (oldValue != null) getChildren().remove(oldValue);
                    if (newValue != null) getChildren().add(0, newValue);
        protected void handleValidationResult(ValidationResult result) {
            getStyleClass().removeAll("validation-error", "validation-warning");
            if (result != null) {
                if (result.getType() == ValidationResult.Type.ERROR) {
                    getStyleClass().add("validation-error");
                } else if (result.getType() == ValidationResult.Type.WARNING) {
                    getStyleClass().add("validation-warning");
            validationResult.set(result);
            fireEvent(new ValidationEvent(result));
        @Override
        protected void layoutChildren() {
            Control c = content.get();
            if (c != null) {
                c.resizeRelocate(0, 0, getWidth(), getHeight());
        @Override
        protected double computeMaxHeight(double d) {
            Control c = content.get();
            return c == null ? super.computeMaxHeight(d) : c.maxHeight(d);
        @Override
        protected double computeMinHeight(double d) {
            Control c = content.get();
            return c == null ? super.computeMinHeight(d) : c.minHeight(d);
        @Override
        protected double computePrefHeight(double d) {
            Control c = content.get();
            return c == null ? super.computePrefHeight(d) : c.prefHeight(d);
        @Override
        protected double computePrefWidth(double d) {
            Control c = content.get();
            return c == null ? super.computePrefWidth(d) : c.prefWidth(d);
        @Override
        protected double computeMaxWidth(double d) {
            Control c = content.get();
            return c == null ? super.computeMaxWidth(d) : c.maxWidth(d);
        @Override
        protected double computeMinWidth(double d) {
            Control c = content.get();
            return c == null ? super.computeMinWidth(d) : c.minWidth(d);
    }And finally the TextInputValidatorPane instance good for any TextInputControl. I think.
    import javafx.beans.InvalidationListener;
    import javafx.beans.Observable;
    import javafx.beans.value.ChangeListener;
    import javafx.beans.value.ObservableValue;
    import javafx.scene.control.TextInputControl;
    * @author Richard
    public class TextInputValidatorPane<C extends TextInputControl> extends ValidatorPane<C> {
        private InvalidationListener textListener = new InvalidationListener() {
            public void invalidated(Observable o) {
                final Validator v = getValidator();
                final ValidationResult result = v != null ?
                    v.validate(getContent()) :
                    new ValidationResult("", ValidationResult.Type.SUCCESS);
                handleValidationResult(result);
        public TextInputValidatorPane() {
            contentProperty().addListener(new ChangeListener<C>() {
                public void changed(ObservableValue<? extends C> ov, C oldValue, C newValue) {
                    if (oldValue != null) oldValue.textProperty().removeListener(textListener);
                    if (newValue != null) newValue.textProperty().addListener(textListener);
        public TextInputValidatorPane(C field) {
            this();
            setContent(field);
    }This should also be usable as is from FXML since you can easily wrap a TextInputValidatorPane around a TextField, and CSS does all the styling, so I think it all just works. You probably need to have some library of sophisticated Validators which know how to read text from a TextField and compare against the validation annotations, but otherwise it should work well enough. Anyway, in the actual implementation I think I would omit the ValidationPane stuff completely and just build that part into the controls / skins. Like I said, this was a quick hack but seemed to get the "how do I visualize validation errors" part of the problem solved.
    Richard

  • IDM Form components - more questions looking for answers

    Having gotten deeper into IDM, particularly forms since joining this forum, I am still shocked by the sparse documentation available. here's hoping some of you have found some of this out already:
    1. Is there a list of allowed HTML tags that will get through the getLocalizedString without being filtered?
    2. Is there an up-to-date list of allowed properties for Form HTML Components? I have tried verbatim several examples from the documentation where I add properties to the EditForm component only to see them throw an exception when the server tries to display the page
    3. Is there any way to consistently override IDM putting a nowrap="nowrap" attribute in my forms? I have placed <Property name='nowrap' value='false'/> in numerous locations to no avail.
    4. Where can I find more information about setting defaults in the Component Properties object? I have tried to set a lot of component defaults here but only some seem to work.
    Any and all help will be rewarded with much praise and thanks.

    Hi Laxmi,
    I hope most of the questions you have asked could be found through search....
    Regarding Q8. you can go through this link
    Re: customisation of infotypes
    Thanks
    Kishore

Maybe you are looking for

  • How can I remove rests from the score?

    I am an amateur pianist and recording my score I hesitated and rests were added to the score. When I click on them, nothing happens as they do not highlight. How can I get rid of the black rectangle bode rests on the treble and bass clefs? MacBook Pr

  • Screen Resolution in table control bdc

    Hi , Im working on bdc table control using call transaction method for vk11 and mek1.While uploading data for vk11 for the first time it is taking all the records of the input file and if i do the same for the second time by changing the amount value

  • Audio problems preloaded Captivate swfs in custom player

    I have a slideshow-like custom Flash player that uses standard preloader code - it loads external swf movieclips into a holder clip, and stores references to them in an array. Once all external swfs are loaded, the first clip starts playing and navig

  • Bar code for materials.

    Hi Friends,                   Our client wants to maintain bar code for the vendor provided material no.s. For vendor materil no.s we are using the old material numbers.so please explain how to use thisbar code for goods reciept, issue etc...please r

  • How to create  search help for field in interactive adobe form

    HI I want to create search help for PERNR field in adobe form. how i can do it. Can any one giud me. Regards, Laxman Sankhla