Spry textfield validation

Hi, how can I modify this code for the spry textfield validation.js file? My text field is set to yyyy-mm-dd.  When I enter a date and hit the submit button all works well but, how can I modify this portion of the .js file so the date yyyy-mm-dd is not less than today's date?
===================
'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;
======================
Thanks Winrol

V1 Fusion wrote:
> Yes you can use regular expessions:
>
> function validatePhone(value){
> return
>
/^(((\+44\s?\d{4}|\(?0\d{4}\)?)\s?\d{3}\s?\d{3})|((\+44\s?\d{3}|\(?0\d{3}\)?)\s?
>
\d{3}\s?\d{4})|((\+44\s?\d{2}|\(?0\d{2}\)?)\s?\d{4}\s?\d{4}))(\s?\#(\d{4}|\d{3})
> )?$/.test(value)
> }
>
> var custom = new Spry.ValidationTextField(id, "custom",
{validation:
> validatePhone, validateOn:["blur", "change"]})
>
> regexp from
http://regexlib.com/
Excellent, thank you, that will get me in the right
direction. Its not
100%, but I think I can tinker with an expression to get what
I want.
The number is couldn't handle is +44 (0)113 255 7666 but its
not an
approved format anyway, but lots of companies still do it
this way, so I
want to ensure I get it right.
Thanks again!
Dooza
Posting Guidelines
http://www.adobe.com/support/forums/guidelines.html
How To Ask Smart Questions
http://www.catb.org/esr/faqs/smart-questions.html

Similar Messages

  • UI Datepicker and Spry textfield Validation

    Hi, I am having a problem with using the UI Date picker and Spry textfield Validation together. I have created a sample form: 2 input boxe, the test box has the datepicker and spry validation and test2 has the date picker only,one submit button and some php code that echos the boxes values on submit.
    My date picker is date formated as 'yy-mm-dd' for four digit year.  My spry validation is formated 'yyyy-mm-dd' with validate on submit.
    Now when I click on the test input box the datepicker comes up normally and i select a date. I then select the date on test2. Once I click the submit button the test field with spry validation come back saying a value is required and nothing else happens.
    I was playing around and trying other things to get it to work and I noticed that when I select the test inputbox and the calander pops up if I enter some numbers into the text box then select a date from the datepicker then enter a date in the test2 inputbox and hit submit it works.
    So it appears to me that the validation is not reading anything in the test field when I just select a date.  Why is that?  When I select a date it shows a date in the inputbox.  It makes it hard to use the datepicker on a form.
    Any help would be a preciated.  Code is below.
    Thanks Winrol
    <?php echo "Test box 1 value = ". $_POST['test']. "<br/>" ?>
    <?php echo "Test box 2 value = ". $_POST['test2'] ?>
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
    <title>Untitled Document</title>
    <script src="jquery-ui-1.7.2/js/jquery-1.3.2.min.js" type="text/javascript"></script>
    <script src="jquery-ui-1.7.2/js/jquery-ui-1.7.2.min.js" type="text/javascript"></script>
    <script src="SpryAssets/SpryValidationTextField.js" type="text/javascript"></script>
    <link href="jquery-ui-1.7.2/css/base/ui.core.css" rel="stylesheet" type="text/css" />
    <link href="jquery-ui-1.7.2/css/base/ui.datepicker.css" rel="stylesheet" type="text/css" />
    <link href="jquery-ui-1.7.2/css/base/ui.theme.css" rel="stylesheet" type="text/css" />
    <link href="jquery-ui-1.7.2/css/base/ui.datepicker.images.css" rel="stylesheet" type="text/css" />
    <style type="text/css">
    /* BeginOAWidget_Instance_2137022: #datepicker */
    #datepicker .ui-widget {
    font-family: inherit;
    #datepicker .ui-datepicker {
    font-family: "Trebuchet MS", Arial, Helvetica, sans-serif;
    #datepicker .ui-datepicker-title {
    font-family: "Trebuchet MS", Arial, Helvetica, sans-serif;
    font-size: 1.1em;
    color: #000;
    font-weight: normal;
    line-height: 1.8em;
    #datepicker .ui-state-default, .ui-widget-content .ui-state-default {
    border-color: #e6e6e6;
    background-color: #e6e6e6;
    color: #555555;
    #datepicker .ui-state-default, .ui-state-default a {
    color: #555555;
    #datepicker .ui-state-highlight, .ui-widget-content .ui-state-highlight {
    border-color:#FCEFA1;
    background-color:#FCEFA1;
    color:#363636;
    #datepicker .ui-state-active, .ui-widget-content .ui-state-active {
    border-color: #FFFFFF;
    background-color: #FFFFFF;
    color: #212121;
    #datepicker .ui-state-hover, .ui-widget-content .ui-state-hover, .ui-state-focus, .ui-widget-content .ui-state-focus
    border-color: #5F5F5F;
    background-color: #5F5F5F;
    color: #212121;
    #datepicker .ui-widget-header
    border-color: #5F5F5F;
    background-color: #808080;
    border-width: 1px;
    /* Text attributes for the Days of Week Text */
    #datepicker .ui-datepicker table th
    font-size: .8em;
    color: #000;
    font-weight: bold;
    /* EndOAWidget_Instance_2137022 */
    </style>
    <script type="text/xml">
    <!--
    <oa:widgets>
      <oa:widget wid="2137022" binding="#datepicker" />
    </oa:widgets>
    -->
    </script>
      <script type="text/javascript">
    // BeginOAWidget_Instance_2137022: #datepicker
    $(function() {
    $('input').filter('.datepicker').datepicker({dateFormat: 'yy-mm-dd'});
    // EndOAWidget_Instance_2137022
      </script>
    <link href="SpryAssets/SpryValidationTextField.css" rel="stylesheet" type="text/css" />
    <style type="text/css">
    body {
    background-color: #FFC;
    </style>
    </head>
    <body>
    <form id="form1" name="form1" method="post" action="">
      <p>
        <label for="test">test</label>
        <span id="sprytextfield1">
        <input name="test" type="text" class="datepicker" id="test"/>
        <span class="textfieldRequiredMsg">A value is required.</span><span class="textfieldInvalidFormatMsg">Invalid format.</span></span></p>
      <p>
        <label for="test2">test2</label>
        <input name="test2" type="text" id="test2"  class="datepicker" />
      </p>
      <p onclick="<?php echo $_POST['test'] ?>">
        <input type="submit" name="submit" id="submit" value="Submit" />
      </p>
    </form>
    <script type="text/javascript">
    var sprytextfield1 = new Spry.Widget.ValidationTextField("sprytextfield1", "date", {format:"yyyy-mm-dd", hint:"yyyy-mm-dd"});
    </script>
    </body>
    </html>

    This does work
    <!DOCTYPE HTML>
    <html>
    <head>
    <meta charset="utf-8">
    <title>Untitled Document</title>
    <link href="SpryAssets/SpryValidationTextField.css" rel="stylesheet">
    <link href="jquery-ui-1.7.2/css/base/ui.core.css" rel="stylesheet">
    <link href="jquery-ui-1.7.2/css/base/ui.datepicker.css" rel="stylesheet">
    <link href="jquery-ui-1.7.2/css/base/ui.theme.css" rel="stylesheet">
    <link href="jquery-ui-1.7.2/css/base/ui.datepicker.images.css" rel="stylesheet">
    </head>
    <body>
    <form action="" method="post">
    <span id="sprytextfield1">
    <label for="mydate">Date:</label>
    <input id="datepicker" name="mydate" type="text">
    <span class="textfieldRequiredMsg">A value is required.</span><span class="textfieldInvalidFormatMsg">Invalid format.</span></span>
    <div id="datepicker" class="ui-glass-gradient ui-80TopTo0Bottom-gradient-header"></div>
    <input name="mysubmit" type="submit">
    </form>
    <script src="SpryAssets/SpryValidationTextField.js"></script>
    <script src="jquery-ui-1.7.2/js/jquery-1.3.2.min.js"></script>
    <script src="jquery-ui-1.7.2/js/jquery-ui-1.7.2.min.js"></script>
    <script>
    var sprytextfield1 = new Spry.Widget.ValidationTextField("sprytextfield1", "date", {format:"mm/dd/yyyy", validateOn:["change"], useCharacterMasking:true});
    $(function() {
        $('#datepicker').datepicker({ showOtherMonths: false });
    </script>
    </body>
    </html>
    Gramps

  • Function to call spry textfield validation

    Hi every body.
    I've a question for you.
    I'm using a filed spry text field validation. It works perfectly when y press submit, but I need to do this:
    I put some text in a textfield using PHP, the validation is only maked when I click the text field, or when  the user press a key, but how to make a function to do the validation after I put data on textfield.

    Click the on Blur as per
    Gramps

  • Spry textfield validation for alphanumeric input

    Hi,
    How can I set the spry input to the following pattern that I need: only allow alphanumeric.

    You can build your own custom validations with Spry.
    var custom = new Spry.Widget.ValidationTextField("id", "custom", {
         validation: function( value, options ){
              return /[a-z]/gi.test( value ); // your validation
    Related reading:  http://labs.adobe.com/technologies/spry/articles/textfield_overview/index.html and http://labs.adobe.com/technologies/spry/samples/validationwidgets/TextfieldValidationSampl e.html

  • Spry textfield validation with custom pattern

    I have sussed out the standard custom pattern, and how to
    enforce it,
    but what I would like to know is how can I allow any numbers,
    including
    spaces, brackets, or plus sign, but no letters?
    This is for a phone number entry field, where it could be an
    international phone number or a standard one for the UK,
    where the
    length can vary, depending on where you live.
    http://en.wikipedia.org/wiki/Telephone_numbers_in_the_United_Kingdom)
    Any ideas?
    Dooza
    Posting Guidelines
    http://www.adobe.com/support/forums/guidelines.html
    How To Ask Smart Questions
    http://www.catb.org/esr/faqs/smart-questions.html

    V1 Fusion wrote:
    > Yes you can use regular expessions:
    >
    > function validatePhone(value){
    > return
    >
    /^(((\+44\s?\d{4}|\(?0\d{4}\)?)\s?\d{3}\s?\d{3})|((\+44\s?\d{3}|\(?0\d{3}\)?)\s?
    >
    \d{3}\s?\d{4})|((\+44\s?\d{2}|\(?0\d{2}\)?)\s?\d{4}\s?\d{4}))(\s?\#(\d{4}|\d{3})
    > )?$/.test(value)
    > }
    >
    > var custom = new Spry.ValidationTextField(id, "custom",
    {validation:
    > validatePhone, validateOn:["blur", "change"]})
    >
    > regexp from
    http://regexlib.com/
    Excellent, thank you, that will get me in the right
    direction. Its not
    100%, but I think I can tinker with an expression to get what
    I want.
    The number is couldn't handle is +44 (0)113 255 7666 but its
    not an
    approved format anyway, but lots of companies still do it
    this way, so I
    want to ensure I get it right.
    Thanks again!
    Dooza
    Posting Guidelines
    http://www.adobe.com/support/forums/guidelines.html
    How To Ask Smart Questions
    http://www.catb.org/esr/faqs/smart-questions.html

  • Spry textfield validation (group)

    I have three text fields where only one requires an entry -- any one of the three.
    How would I group validate those three text fields to ensure an entry in any one of them?

    Thanks here too, Arnout.  That code just does not make sense to me. See note at other message to you.
    This also seems a simple task for a pro.  If field1 or field2 or field3 > 0 then, Spry fails to validate.  Shouldn't it be as simple as pass/fail based on the three fields entries?
    Again, it seems easy for a non-Javascript writer.  Is there a simple solution for a tweaker like me?

  • Spry textfield: email

    Hello All,
    I'm using the email feature in the SPRY textfield validation,
    but in my INTRAnet that we use, alot of our email addresses include
    a '+' at the beginning. The SPRY validation rules do not allow for
    this character in the textfield.
    How can I allow the validator to allow the + (plus):
    [email protected]
    I tried to delete the " value=='+' " in the js, but it
    doesn't change anything.
    Looking forward to hearing from the community.
    Cheers!
    Kevin

    Hello Again,
    I have been doing some reading about the plus sign (+) and it
    is really a valid character in the local part of an email address.
    According to RFC2822, the local part of the email (before the @)
    may contain:
    * Uppercase and lowercase letters (case sensitive)
    * The digits 0 through 9
    * The characters ! # $ % * / ? | ^ { } ` ~ & ‘ + -
    = _
    * The character . provided that it is not the first or last
    character in the local-part.
    http://en.wikipedia.org/wiki/E-mail_address
    - and -
    http://tools.ietf.org/html/rfc2822
    So is this an oversite by the SPRY team? A Bug?
    Cheers!
    Kevin

  • Spry Textfield date validation

    I have a Spry textfield for a user to enter a date. I want to
    limit the date entered to 31 days away from the current date. Can
    anyone help me out with this or provide directions to an article to
    help solve this issue?
    Pat

    This does work
    <!DOCTYPE HTML>
    <html>
    <head>
    <meta charset="utf-8">
    <title>Untitled Document</title>
    <link href="SpryAssets/SpryValidationTextField.css" rel="stylesheet">
    <link href="jquery-ui-1.7.2/css/base/ui.core.css" rel="stylesheet">
    <link href="jquery-ui-1.7.2/css/base/ui.datepicker.css" rel="stylesheet">
    <link href="jquery-ui-1.7.2/css/base/ui.theme.css" rel="stylesheet">
    <link href="jquery-ui-1.7.2/css/base/ui.datepicker.images.css" rel="stylesheet">
    </head>
    <body>
    <form action="" method="post">
    <span id="sprytextfield1">
    <label for="mydate">Date:</label>
    <input id="datepicker" name="mydate" type="text">
    <span class="textfieldRequiredMsg">A value is required.</span><span class="textfieldInvalidFormatMsg">Invalid format.</span></span>
    <div id="datepicker" class="ui-glass-gradient ui-80TopTo0Bottom-gradient-header"></div>
    <input name="mysubmit" type="submit">
    </form>
    <script src="SpryAssets/SpryValidationTextField.js"></script>
    <script src="jquery-ui-1.7.2/js/jquery-1.3.2.min.js"></script>
    <script src="jquery-ui-1.7.2/js/jquery-ui-1.7.2.min.js"></script>
    <script>
    var sprytextfield1 = new Spry.Widget.ValidationTextField("sprytextfield1", "date", {format:"mm/dd/yyyy", validateOn:["change"], useCharacterMasking:true});
    $(function() {
        $('#datepicker').datepicker({ showOtherMonths: false });
    </script>
    </body>
    </html>
    Gramps

  • Spry textfield issue

    I'm using a spry textfield, and am enforcing a specific
    pattern (AA00000000A). Is there a way to allow/specify more than
    one pattern?

    Al Sparber- PVII wrote:
    > "eclipsme" <[email protected]> wrote in message
    > news:fcjsoh$3m1$[email protected]..
    >> Al Sparber- PVII wrote:
    >>> "skipiouk" <[email protected]>
    wrote in message
    >>> news:fciqsg$t8i$[email protected]..
    >>>> Thanks Al
    >>>> is there no way to do this inside CS3 or is
    the purchase of piece of
    >>>> software necessary?
    >>>> Neil
    >>>
    >>> I don't know. We do not use Spry because it's
    just not compatible
    >>> with our approach towards markup, CSS, or
    scripting. If you are a
    >>> casual web developer and don't have a
    professional budget, perhaps
    >>> someone who is "into" Spry can help you hack a
    solution.
    >>>
    >>>
    >> See if this helps.
    >>
    >>
    http://labs.adobe.com/technologies/spry/articles/accordion_overview/
    >>
    >> Harvey
    >
    > Hi Harvey,
    >
    > I don't need "help" understanding how Spry widgets work.
    We have
    > analyzed the code and methodology and it's just an
    approach that we
    > would never take, hence we have no interest in it.
    Perhaps you meant
    > your post to be in response to someone else and not me
    >
    >
    Right, Al. Niel was asking the question. Your's wasn't the
    only post.
    Sorry if you got confused. The link provides information on
    configuring
    the widget. I thought this could be useful to Niel.
    Harvey

  • Conditional Spry Confirm Validation

    Hi Chaps,
    I know there are a few of these threads about, however, the answers usually point to a 404 webpage.
    I'm after a conditional Spry Confirm Validation Text Field.
    E.G. if a user decides to change a password, the (required) confirm validation comes into effect.
    If anyone can point me in the right direction, it would help me out.
    Many thanks
    Samuel

    never mind, found this: http://forums.adobe.com/message/2983481#2983481#2983481

  • Error in TextField Validation Widget reset() method

    There appears to be an error in the Textfield Validation
    Widget's reset() method. When I set the widget to "real" or
    "custom" validation, the reset() method is throwing an error when
    it reaches the line "this.oldValue = this.input.defaultValue;"
    I seached the code and it appears that
    "this.input.defaultValue" is not set anywhere else. Is there a
    missing option, or is this line incorrect and copied over from
    another widget that uses "defaultValue"?

    It looks as though you're trying to use main-content as a CSS selector. If it's a class, it should begin with a dot (period) like this:
    .main-content
    If it's an ID selector, it should begin with a hash:
    #main-content

  • TextField Validation in swings

    Hello friends,
    i got a problem. i am doing textfield validation using KeyListener.
    i can able to detect the keys except Tab key.
    When i am pression TAB key the KeyListener is not catching the event.
    Actually validation should be in such a way that,
    in account number field if i press anyotherkeys otherthan numeric ,del,backspace keys it should not allow to enter.
    also it has to give error if user tries to move from that field without entering anydata by pressing TAB or Mouse.
    Here exactly getting problem with focus.
    Please give your advise
    thanks in advance
    regards
    shashi

    TextField Validation in swingsOk, you know its a Swing question, so it should be posting in the Swing forum.
    if i press anyotherkeys otherthan numeric ,del,backspace keys it should not allow to enter.You should be using a JFormattedTextField
    it has to give error if user tries to move from that field without entering anydata You could try an InputVerifier.

  • Multiple TextField Validation

    I want to do this:
    I have 3 textfields, when I click the submit button I want
    the validation to check whether there's data in any of the
    textfields (at least in one) if so, then all three textfields are
    Valid, if non of the textfield have data then all 3 textfields are
    invalid.
    Is this posible in Spry Framework 1.6.1; if so how is this
    done?
    I tried a custom validating function with option isRequired:
    false on and off without luck.

    Ok.Well I cannot provide link to the full page as the site is
    not up and running yet. However, here's the full html code;
    ofcourse you need to update the link to the spry code. I am using
    spry 1.6.
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0
    Transitional//EN" "
    http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="
    http://www.w3.org/1999/xhtml">
    <head>
    <meta http-equiv="Content-Type" content="text/html;
    charset=utf-8" />
    <title>Untitled Document</title>
    <script src="../SpryAssets/SpryValidationTextField.js"
    type="text/javascript"></script>
    <link href="../SpryAssets/SpryValidationTextField.css"
    rel="stylesheet" type="text/css" />
    </head>
    <body>
    <form id="brochurereq" name="brochurereq" method="post"
    action="test.html">
    <input type="submit" value="Send" name="Send" />
    <span id="text1">
    <input type="text" name="firstname" id="firstname" />
    <span class="textfieldRequiredMsg">The value is
    required.</span>
    </span>
    <span id="text2">
    <input type="text" name="lastname" id="lastname" />
    <span class="textfieldRequiredMsg">The value is
    required.</span>
    </span>
    </form>
    <script type="text/javascript">
    <!--
    var sprytext1 = new Spry.Widget.ValidationTextField("text1",
    "none");
    var sprytext2 = new Spry.Widget.ValidationTextField("text2",
    "none");
    //-->
    </script>
    <body>
    </body>
    </html>

  • Textfield validation with XML Data

    hello
    can i validation a textfield with data from a XML file?
    i will read eg usernames form an XML file and will check it
    with a username was typed in in a textfield,
    if the username exits the textfield is invalid, since the
    username was typed in, is not in the XML file.
    thanks
    jack

    Hello,
    I don't advise you to make such an scenario. The solution you
    propose involve some high security risks and privacy problems
    because you send to the browser a complete list of users of your
    website.
    The Spry Validation Textfield supports callback validation
    javascript function. This means you create your own function that
    include the necessary code to validate the user input and pass to
    the widget as parameter the name of your function. A good sample of
    this feature could be seen in the
    Password
    Validation section.
    Regards,
    Cristian

  • SPRY Textfield comparison

    Hi,
    I have 2 textfields on my page for an email and retype email
    and need spry to validate they are equal, my textfields currently
    validate the field is an email and that is fine, what i need to do
    is make sure they are the same before submitting the form.
    Cheers in advance
    Smalls.

    Hello Again,
    I have been doing some reading about the plus sign (+) and it
    is really a valid character in the local part of an email address.
    According to RFC2822, the local part of the email (before the @)
    may contain:
    * Uppercase and lowercase letters (case sensitive)
    * The digits 0 through 9
    * The characters ! # $ % * / ? | ^ { } ` ~ & ‘ + -
    = _
    * The character . provided that it is not the first or last
    character in the local-part.
    http://en.wikipedia.org/wiki/E-mail_address
    - and -
    http://tools.ietf.org/html/rfc2822
    So is this an oversite by the SPRY team? A Bug?
    Cheers!
    Kevin

Maybe you are looking for

  • Script component runtime error

    I have a  package to update and create contacts from a database to an application. So far it is working fine. But if one of the input columns has null value it throws this error: Condition for attribute 'new_lapinterpreter.new_interpreterlanguage': n

  • Trackpad and using quicktime

    I have leopard and love it. I have a couple problems though. First when I double click on an item in my dock using the trackpad it opens up but when i double click using the trackpad for any other function (i.e switching songs in itunes or on an icon

  • Substring in XMLP

    Hi, My report takes data from XML. There is one field which gets its value from the other. For example, the name of the vendor is "Advanced Networks" .Then the name of the "description" field should be the first 5 characters of the vendor name.So the

  • Message type " " is unknown. Transaction J1IF13

    Dear all, When i am executing transaction J1IF13 for Subcontracting i am getting this error "Message type " " is unknown." i want to cancel the transaction Regards Amey

  • OSDCOMputer name issue - MDT2013+SCCM 2012

    Hi ,  I have setup Sequence table along with prefix, and a stored procedure to update the computeridentity table, all works fine it updates the sequence number and computer name  BUT  i am unable to get the OSDCOMPUTERNAME set to same name as compute