Using JavaScript to set value of Spry validated text field

Why can't the value of a text field be set using JavaScript
when it's validated using the Spry validation widget.
Example (this works):
<select name="birthdate_month" id="birthdate_month"
onChange="document.getElementById('birthdate').value = 'test';">
<option>1</option>
<option>2</option>
</select>
<input type="text" name="birthdate" id="birthdate"
value="">
Example (this doesnt work):
<select name="birthdate_month" id="birthdate_month"
onChange="document.getElementById('birthdate').value = 'test';">
<option>1</option>
<option>2</option>
</select>
<span id="birthdate">
<input type="text" name="birthdate" id="birthdate"
value="">
<span class="textfieldRequiredMsg">please enter your
birthday</span>
</span>
<script type="text/javascript">
<!--
var birthdate = new
Spry.Widget.ValidationTextField("birthdate", "none");
//-->
</script>
Is there a way to change the value of a Spry validated text
field using JavaScript?
Thanks.

Why can't the value of a text field be set using JavaScript
when it's validated using the Spry validation widget.
Example (this works):
<select name="birthdate_month" id="birthdate_month"
onChange="document.getElementById('birthdate').value = 'test';">
<option>1</option>
<option>2</option>
</select>
<input type="text" name="birthdate" id="birthdate"
value="">
Example (this doesnt work):
<select name="birthdate_month" id="birthdate_month"
onChange="document.getElementById('birthdate').value = 'test';">
<option>1</option>
<option>2</option>
</select>
<span id="birthdate">
<input type="text" name="birthdate" id="birthdate"
value="">
<span class="textfieldRequiredMsg">please enter your
birthday</span>
</span>
<script type="text/javascript">
<!--
var birthdate = new
Spry.Widget.ValidationTextField("birthdate", "none");
//-->
</script>
Is there a way to change the value of a Spry validated text
field using JavaScript?
Thanks.

Similar Messages

  • Spry validation text field across two columns in a table?

    I have a table with two columns.  I can easily insert a spry validated text field into the left cell but when I drag the box over so that box is in the right column and the label is still in the left column then that breaks the widget.
    Is this even possible for me to do or do I have to put the widget in just one column?

    Think I figured it out.
    http://www.adobe.com/devnet/dreamweaver/articles/spry_form_validations.html

  • Spry validation text field issue

    I've put several spry validation text fields on my site and
    you can still click through to the next page without having to
    enter any information. What am I missing?

    Think I figured it out.
    http://www.adobe.com/devnet/dreamweaver/articles/spry_form_validations.html

  • Possible to change type of spry validation text field at run time?

    I am trying to record a date of death on a form, which obviously for live people might not require a value. I have a radio group (Yes/No) that specifies whether the fields associated with the date of death are visible (select for month, day and year).  For the year, I have it set to be an integer with a minimum and maximum value.  The selects have an invalid value of -1 set, with one item labeled "Select month" and "Select day" given the -1 value.
    When the "no" button is clicked, I want to make it so that submitting the form does not cause validation errors for the spry fields associated with the date of death.  I have successfully added onChange events to the select objects that call javascript, along the lines of spryselect1.invalidValue = -2.  I can also make it so that the text field representing the year of death is not forced to be required: sprytextfield1.isRequired = false.
    However, I'm having a hard time getting the "invalid format" validation to be canceled.  I have tried executing sprytextfield1.type = "none", since looking at the source code in SpryValidationTextField.js seems to indicate that the object's type property is important.  However, this doesn't work; I think that's because the type property is used to look up a validation function in an array when the object is constructed, and may not be referenced again after that.
    So, I'm looking for either:
    a property/method to call to effectively change the type OR
    information on whether reconstructing the variable with new options will work.  I am not sure if any event handlers registered during the object's original construction will still be fired even if I make the variable point to a new object.  I see a destroy function in the source code that might do what I want, but my Javascript knowledge isn't too great, so I don't know if that method needs to be called explicity or whether it happens implicitly when an object is garbage collected.
    Thanks in advance for any help you might be able to give.
    Ryan

    This may help
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1" />
    <title>Deleting and rebuilding validations</title>
    <link href="http://config.spry-it.com/css?f=ValidationTextField" rel="stylesheet" type="text/css" />
    <script src="http://config.spry-it.com/js?f=ValidationTextField" type="text/javascript"></script>
    <script type="text/javascript">
    // build validations and delete / destroy them
    function val(e){
         // get the value
         value = e.value;
         // see what radion button we have
         if(value == "Married"){
              // if there inst a validaton build one
              if(!sprytextfield1){
                   sprytextfield1 = new Spry.Widget.ValidationTextField("sprytextfield1");
              // if there is a validaiton in sprytextfield destory it, and clear the variable
              if(sprytextfield2 && sprytextfield2.destroy){
                   sprytextfield2.resetClasses();
                   sprytextfield2.destroy();
                   sprytextfield2 = null;
              // same as the rest
              if(sprytextfield3 && sprytextfield3.destroy){
                   sprytextfield3.resetClasses();
                   sprytextfield3.destroy();
                   sprytextfield3 = null;
         } else if(value == 'Defacto'){
              if(!sprytextfield2){
                   sprytextfield2 = new Spry.Widget.ValidationTextField("sprytextfield2");
              if(sprytextfield1 && sprytextfield1.destroy){
                   sprytextfield1.resetClasses();
                   sprytextfield1.destroy();
                   sprytextfield1 = null;
              if(sprytextfield3 && sprytextfield3.destroy){
                   sprytextfield3.resetClasses();
                   sprytextfield3.destroy();
                   sprytextfield3 = null;
         } else if(value == 'Single'){
              if(!sprytextfield3){
                   sprytextfield3 = new Spry.Widget.ValidationTextField("sprytextfield3");
              if(sprytextfield1 && sprytextfield1.destroy){
                   sprytextfield1.resetClasses();
                   sprytextfield1.destroy();
                   sprytextfield1 = null;
              if(sprytextfield2 && sprytextfield2.destroy){
                   sprytextfield2.resetClasses();
                   sprytextfield2.destroy();
                   sprytextfield2 = null;
         // proceed with the rest as normal
         return true;
    </script>
    </head>
    <body>
    <form id="form1" method="post" action="#">
         <p>
              <input type="radio" name="radio" id="Married" value="Married" onclick="val(this);" />
              <label for="Married">Married</label>
         </p>
         <p>
              <input type="radio" name="radio" id="Defacto" value="Defacto" onclick="val(this);" />
              <label for="Defacto">Defacto</label>
         </p>
         <p>
              <input type="radio" name="radio" id="Single" value="Single" onclick="val(this);" />
              <label for="radio">Single</label>
         </p>
         <hr />
         <span id="sprytextfield1">
         <input name="married" id="f_married" type="text" value="forMariedOnly" />
         <span class="textfieldRequiredMsg">A value is required.</span></span><span id="sprytextfield2">
         <input name="defacto" id="f_defacto" type="text" value="forDefactoOnly" />
         <span class="textfieldRequiredMsg">A value is required.</span></span><span id="sprytextfield3">
         <input name="single" id="f_single" type="text" value="forSingleOnly" />
         <span class="textfieldRequiredMsg">A value is required.</span></span>
         <hr />
         <input type="submit" value="Submit" />
    </form>
    <script type="text/javascript">
    <!--
    // as Married is checked by default, we need to validate this field only
    var sprytextfield1,
         sprytextfield2,     // empty global var
         sprytextfield3; // empty global var
    //-->
    </script>
    </body>
    </html>
    Gramps

  • Spry Validation-text field shows the "required" text even in initial state

    Hi,
    I'm having trouble with spry validation.
    I insert my spry textfied and go to the properties inspector where  I choose validate on "Blur" and "submit" for the Required state. I check the required box for the "required state" but the initial state will also have the "a value is required" text. If I try to delete the "a value is required" text from the initial state, the required state won't show this error.
    What should I do?
    Any help is much appreciated.
    Thank you.

    Hi, thanks so much for the reply
    Well the javascript came with the spry file that I downloaded from the adobe site.
    Here is my statement:
      <label for="name"><span class="style87">Name:</span></label>
                      <span id="sprytextfield1">
                      <input name="name" type="text" class="textInput" id="name" />
                      <span class="textfieldRequiredMsg">A value is required.</span>                  </span></p>
                  <p> <span class="style87">
                      <label for="email">Email:</label>
                      </span><span id="sprytextfield2">
                      <input name="email" type="text" class="textInput" id="email" />
                      <span class="textfieldRequiredMsg">A value is required.</span></span></p>
    This is the statement for the submit button:
      <span class="clearIt">
                      <input name="send" type="submit" id="send" onclick="MM_validateForm('username','','R','password','','R','name','','R','email','','R' ,'comments','','R');return document.MM_returnValue" value="Send comments" />
                    </span><span class="clearIt">
                    <input type="hidden" name="MM_insert" value="form1" />
    This is the javascript
    <script type="text/javascript">
    <!--
    function MM_validateForm() { //v4.0
      if (document.getElementById){
        var i,p,q,nm,test,num,min,max,errors='',args=MM_validateForm.arguments;
        for (i=0; i<(args.length-2); i+=3) { test=args[i+2]; val=document.getElementById(args[i]);
          if (val) { nm=val.name; if ((val=val.value)!="") {
            if (test.indexOf('isEmail')!=-1) { p=val.indexOf('@');
              if (p<1 || p==(val.length-1)) errors+='- '+nm+' must contain an e-mail address.\n';
            } else if (test!='R') { num = parseFloat(val);
              if (isNaN(val)) errors+='- '+nm+' must contain a number.\n';
              if (test.indexOf('inRange') != -1) { p=test.indexOf(':');
                min=test.substring(8,p); max=test.substring(p+1);
                if (num<min || max<num) errors+='- '+nm+' must contain a number between '+min+' and '+max+'.\n';
          } } } else if (test.charAt(0) == 'R') errors += '- '+nm+' is required.\n'; }
        } if (errors) alert('The following error(s) occurred:\n'+errors);
        document.MM_returnValue = (errors == '');
    //-->
    </script>
    This is at the bottom of the page:
    <script type="text/javascript">
    <!--
    var sprytextfield1 = new Spry.Widget.ValidationTextField("sprytextfield1", "none");
    var sprytextfield2 = new Spry.Widget.ValidationTextField("sprytextfield2", "none", {validateOn:["blur"]});
    //-->
    </script>
    Thank you for your help.

  • Having Problems with "pattern" in Spry Validation Text Field

    Hi, thanks for reading. I have read the primers and docs on
    using the "custom" pattern ability of the spry textfield validion.
    However, I am unable to fully understand how to implement the
    conditions I desire. I have read that you use:
    "B"; "b" for Case-insensitive alphabetic characters.
    I suppose my first question is, does that mean either B or b
    will work?
    What I am trying to accomplish for my first validation is:
    1- to allow between 1 and 15 characters to be entered. They
    should be only a) alphanumeric (number or letter) b) they MAY
    contain a space in there and c) the first character needs to be a
    letter. So, what I want it to scrub for is a char string no longer
    than 15 chars, number or letter (may contain a space, but that
    counts towards the 15) and the first char must be a letter.
    I have been playing around with the attributes:
    ("spryCustomtest", "custom", {validateOn:["blur"],
    minChars:1, maxChars:15, pattern:"a"});
    however, i am unable to see how to specify the pattern so
    that it allows for 1-15 chars and insists that only the first char
    is a letter......
    My second question is, how could I implement a field for
    heightened password-choosing rules....
    perhaps tell it to allow for:
    a) minimum of 8 characters
    b) at least one capital letter
    c) at least one special character or number
    d) maximum of 30 characters
    thanks for any help, Tex

    Did you ever find a solution for this?

  • Spry Validation Text Field widget

    I want to make sure users insert a properly formatted email
    address, which I found out how to do here.
    http://livedocs.adobe.com/en_US/Spry/1.4/help.html?content=WSC7D22C22-1123-4e9b-8218-F317C DD39F2B.html
    The problem is that when the user inserts an invalid email
    address the text box stays red but no error message displays. How
    do I go about having the error message show. Right now it only
    shows if they leave the box blank.

    I went to
    http://labs.adobe.com/technologies/spry/demos/formsvalidation/
    to try to get an idea how they did their form and they have check
    marks and x to better define their section. It seems all the
    customizing requires knowledge of Javascript which I am not too
    strong in. I guess there is no menu driven method to duplicate that
    form.
    Looks like nobody else has played with form validation
    either.

  • Spry Validation Text Box - Playing Nicely w/ Javascript

    Greetings-
    I'm using the Spry Validation Text Fields in a registration
    form I'm designing. I really like the validation they provide.
    However, I'm trying to get them to play nicely with a password
    validation Javascript code that gets called when the form is
    submitted:
    Form Example
    The password validation JS compares the two email fields to
    make sure they are both the same. The JS is called when the form is
    submitted.
    <SCRIPT LANGUAGE="JavaScript">
    <!-- Begin
    function checkPw(form) {
    pw1 = form.password.value;
    pw2 = form.password_confirm.value;
    if (pw1 != pw2) {
    alert ("\nYour password confirmation failed. Please enter
    your passwords again.")
    return false;
    else return true;
    // End -->
    </script>
    However, this disables the Spry text field validations. I'm
    most certain my "OnSubmit" code causes the Spry validation to not
    execute.
    Any gurus have some ideas around this?
    Thank you.

    Your are going to love this...
    I confirmed I have the constructor same as yours.  Only difference in your code and mine is I did not have the validateOn blur in the Javascript, but rather was using the default validation on submission.  However, I dutifully added that, just to replicate your test exactly and to look at apples to apples.  The code is still throwing up the validation messages.
    Stumped, I took a break, played a video game, cleared the mind and started the process of carefully and logically working the code for about the umpteenth time in the last 24 hours.
    Given this validation is working just fine on the page where new items are created, I laid out that pages code next to the edit page code and started going through line by line... and Eureka!  No reference in my edit page head to the SpryValidationTestField.js... (**red faced, banging head on desk**)
    That's 2 for 2 with you helping me realize its not the Spry code, so it must be something else and that something else, once again, was me.  The human error element.  If I hit strike three down the road I deserve a sound verbal thrashing...
    Once again I am in your debt and you have my gratitude!
    Thank you Gramps!

  • How  to show password in spry validation password field?

    how do  I make the password display in the spry validation password field , the standard one is just a bunch of asterisk .

    Just use a normal textfield, instead of a password field. The only difference between a password field and a text field is the characters not showing up.

  • Where is Hint Box for Validation Text Field widget?

    I want to enter a hint for my form.
    I am following the instructions on the Adobe Using Dreamweaver CS4 page for Insert and edit the Validation Text Field widget page:
    <http://help.adobe.com/en_US/Dreamweaver/10.0_Using/WSEB5440BC-453A-4101-928C-302199E7E02F. html#WS8E6EA74E-87AC-4a81-A5CC-2DB6FB451DE0a>
    It says:
    Create a hint for a text field
    Because there are so many different kinds of formats for text fields, it is helpful to give your users a hint as to what format they need to enter. For example, a text field set with the Phone Number validation type will only accept phone numbers in the form (000) 000-0000. You can enter these sample numbers as a hint so that the text field displays the correct format when the user loads the page in a browser.
       1. Select a Validation Text Field widget in the Document window.
       2. In the Property inspector (Window > Properties), enter a hint in the Hint text box.
    However, the is no hint box in my Propeties area.
    How do I get this hint box to show up?
    Dreamweaver CS4, Windows Vista

    Hi David,
    My Property inspector looks different than what you have below.
    I do not have a Hint box and I do not have the Customize this widget.
    I did have a Hint box and the Customize this widget for CS3, howver not for CS4
    Alison

  • How to show $ sign alongwith the value in message styled text field.

    Hi,
    How to show $ sign alongwith the value in message styled text field.
    The value is coming from the table column in VO.
    I am working on OAF R12.

    Hi,
    Resolved.
    I used the below code in CO for the solution.
    Formatter currencyFormatter = new OADecimalValidater("$#,##0.00;($#,##0.00)",
    "$#,##0.00;($#,##0.00)");
    OAMessageStyledTextBean msrpField = (OAMessageStyledTextBean)webBean.findChildRecursive("MSRP11");
    msrpField.setAttributeValue(ON_SUBMIT_VALIDATER_ATTR, currencyFormatter);

  • Using javascript to set non database values

    I finally figured out how to set the values of a non database form field using Javascript. The only problem is, I want this
    field to be a display only field, and the value does not get set if I make the field non updateable on the form. Can
    somebody please help me!! This is urgent.

    Stan,
    One way to do this is to call the doSubmit() function and create a page branch to handle your request. This way you can use apex validations and other goodies if your requirements change. Also this will save the state of your items on the page you are leaving.
    Edit
    I forgot to mention that you can pass a string parameter to the doSubmit function. The parameter will be the request sent to apex. For instance you could use doSubmit('DO_SOMETHING') and you can have a page branch which will fire if the request is equal to DO_SOMETHING.
    Cheers,
    Tyson Jouglet
    Edited by: Tyson Jouglet on Dec 1, 2009 10:11 AM

  • It possible using javascript to change the value of another jsf text field?

    In my case, I have an input text field and would like to copy it's value on the onchange() event into another text field. Using the destination text field's Id and assigning some content with it's .value property

    Woodstock apparently renders some Javascript/DOM with some homegrown widget framework which on its turn renders the HTML DOM tree instead of plain vanilla HTML. Correct me if I'm wrong, to confirm this, just view the generated HTML source of the page.
    After some Googling I found out that you need getProps() and setProps() to get and set element attributes respectively.
    [http://google.com/search?q=webuijsf+domnode+site:sun.com].
    If you stucks with this, I recommend you to post this question at a forum or mailinglist devoted to Woodstock, e.g at their own homepage at dev.java.net or the Netbeans forum at nabble.com. You're here at a Sun JSF forum, not at a Woodstock forum.

  • Using javascript to set relative position of popup

    I currently use the code below to pop up a window. BUt based on different screen resolutions it might not appear where it should be on all monitors. I always want it to the top right. If there a way to do this with javascript. Setting the top/right pixels wont always work, i dont think so anyhow.
    Thanks in advance.
    <script>
    function MDM_openWindow(theURL,winName,features)
    var _W=window.open(theURL,winName,features);
         _W.focus();
    _W.moveTo(750,25);
    </script>
    Click here

    hi....use this to get screen res...then you can use a percantage instead of pixels to place the pop-up...it shows method and height methods to get user resolution...
    <script language="JavaScript">
    var browserheight;
    var iMyHeight;
              var iMyWidth;
    //Gets user's resolution
    iMyHeight = (window.screen.height);
              iMyWidth = (window.screen.width);
    </script>
    hope this helps / steve

  • Setting value in the detail level field using hdr level lov

    i try to set value in the detail table using hdr LOV , at that time some fields value are set and some are not set. i don't understand why this happens, please give me the solution

    huh?
    You provide nowhere near enough information for us to even understand what you want to do, let alone to answer.
    John

Maybe you are looking for

  • Display issue for xRPM CAPACITY MANAGEMENT  report on EP

    Experts, I am using xRPM 4.2 version. My BW is on release 700 with patch level 15 & EP on 7.0 I am tring to view the various reports uder capacity management on EP. These reports are viewable correctly in BIW system but not able to display the same o

  • Notification Error when using PL/SQL document

    I have a notification that calls a procedure that returns some HTML body of the email. It worked once, but now I get the error below. In Oracle Apps on the notification tab the notification shows correctly, it's the actual sending of the email that i

  • Impact of Desktop Themes on Performance

    Will allowing end-users to select an alternate theme have a measurable effect on the total amount of personalization information stored for the users in the SAP database tables? Has the SAP Portal team seen any other large customers with multiple por

  • 5.0.2 update?

    Any body know when a new update will be out?   We need it

  • Program HR_SYNC_PERSON query

    Helle Experts, On running program hr_sync_person,  a warning message is generated, it reads:      'There is no address for business partner 9999999999' Message class = R1; Message Nr =  612. We are sync'ng our employees to BP via CP; i.e P ==> CP ==>