validation thread

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • dkyadav80
    New Member
    • Jul 2008
    • 21

    validation thread

    Hi
    I have prototype.js script.js, validate_form.j s and lib,src forlder for valdate the user registration. i want to use other field validation. when user click from drop down "other" then are displaying other text field and i putted validation="urt _m"
    it works fine. but when user does not wnt select from other only wnt select from drop down menu and submit then other field not displaying but message displaying " * mondatory field" but this not should be. this shoud be when user select only other field. and java script problem displaying:
    " Line:1595
    Char:3
    Error:Can't move focus to the control because it is invisible, not enabled, or of a type that does not accept the focus"
    Code:0
    URL: http://localhost/Yretire_new/index.p...ion&action=Add

    [MY code goes here of js -> this is for Hide and show in validate_form.j s]

    [CODE=javascript]function HideShowOther(o bj, id)
    {
    txt = obj.value;
    if ( txt == 'Other')
    {
    Element.show(id );
    }
    else
    Element.hide(id );

    }
    [/CODE]
    [& in Prototype.js]

    [CODE=javascript]Element.Methods = {
    visible: function(elemen t) {
    return $(element).styl e.display != 'none';
    },

    toggle: function(elemen t) {
    element = $(element);
    Element[Element.visible (element) ? 'hide' : 'show'](element);
    return element;
    },

    hide: function(elemen t) {
    $(element).styl e.display = 'none';
    return element;
    },

    show: function(elemen t) {
    $(element).styl e.display = '';
    return element;
    },

    remove: function(elemen t) {
    element = $(element);
    element.parentN ode.removeChild (element);
    return element;
    },
    [/CODE]

    So, Please solve my problem.

    Thanks in advance.
    Last edited by acoder; Aug 5 '08, 10:14 AM. Reason: Added [code] tags
  • acoder
    Recognized Expert MVP
    • Nov 2006
    • 16032

    #2
    The error is caused by focus problems. Show your validation code where you validate the drop-down/other field.

    Please use the code tags properly. Use the # button when posting to wrap your code in code tags. The posting/reply guidelines on the right when you post also show you how to use code tags as does How to Ask a Question in the FAQ.

    Comment

    • RamananKalirajan
      Contributor
      • Mar 2008
      • 608

      #3
      hi, I am suggesting a way that how I used in my code for registration. I kept the Drop down menu in a form and the rest in the other form. When an item is selected from the drop down menu, I set the selected value to an hidden input element in the other form. So we can use that value easily for validartion without any problem.


      Regards
      Ramanan Kalirajan.

      Comment

      Working...