Validate specific numeric field values
Last Post 12-21-2012 05:21 AM by Ryan Bakerink. 3 Replies.
AddThis - Bookmarking and Sharing Button
Author Messages
Matthew CrowshawUser is Offline
wading in the water
wading in the water
Posts:20
Avatar

--
12-07-2012 10:54 AM

    I am creating a form that has a field which will only be allowed to accept one of two values (for security purposes, it can't be a drop down or radio button, the user has to know what it is from a different source).

    For example I would like to only allow either 4521 or 4522 in this field, and if it's not one of those two, present a message to the user.

    Any suggestions on how best to validate the field entry? (I'm a newbie...)

    TIA,

    Matt

    Ryan BakerinkUser is Offline
    river guide
    river guide
    Posts:1900
    Avatar

    --
    12-07-2012 11:47 AM
    Hello Matt,

    This sounds like a great opportunity to utilize JavaScript.

    You should notice when managing a Dynamic Question in Dynamic Forms that under Advanced Question Options you should see a section titled "Client Side". This section acts similar to the OnChange attribute of HTML Input fields.

    So you should be able to add the validation into this area using JavaScript. If the short field name of your question is "TestField" then you should be able to use JavaScript like the script below:

    if($(TestField) != '4521' && $(TestField) != '4522')
    {
    alert('Invalid');
    }
    else
    {
    alert('Valid');
    }


    Please try this script and let me know how it goes for you.

    Let me know if you have any questions.

    Thanks,

    Ryan
    Matthew CrowshawUser is Offline
    wading in the water
    wading in the water
    Posts:20
    Avatar

    --
    12-13-2012 12:03 PM
    Thank you, the javascript works as expected.

    However, I have a very picky customer and they want all error/invalid input messages to be consistent.

    I have tried the 'enable compare validator' successfully (sort of). By default it shows the field. I then hid the field by role, however there is a bit of a lag on the screen and you can see the field disappearing.

    Long explanation for a short question: Is there any way for compare validator to work against a hidden field? The 'compare to' field disappears from the dropdown of available fields when I change it to hidden.

    TIA,
    Matt
    Ryan BakerinkUser is Offline
    river guide
    river guide
    Posts:1900
    Avatar

    --
    12-21-2012 05:21 AM
    Hello Matt,

    I've never tried to use a Compare Validator against a hidden field. It sounds like there might be some conflicts on the page(jQuery).

    You can always use JavaScript to achieve the same thing as the built in Compare Validator. I'm not sure how your site is configured and what all of your environment variables are,but can you confirm if the feature works correctly on non-hidden fields?

    Thanks,

    Ryan


    ---
  • film izle
  • 720 izle
  • film
  • sinema izle
  • film makinesi
  • T�rk�e dublaj film
  • film izle
  • film izle
  • baglan film izle
  • sinema izle
  • 1080 film izle
  • film mercegi