This topic contains 3 replies, has 2 voices, and was last updated by  Dimitar 10 years, 3 months ago.

Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
  • validator problem #58181

    okasha
    Participant

    hello sir

    i have added validation rules to the jqxvalidator but some inputs which i validate i add them to the form based on conditions
    when i click submit , the following message appear
    TypeError: c[0] is undefined

    may you help me please

    validator problem #58203

    Dimitar
    Participant

    Hello okasha,

    This most probably happens because you are trying to validate a field that has not been added to the form. A possible solution is to build the rules dynamically, too.

    Best Regards,
    Dimitar

    jQWidgets team
    http://www.jqwidgets.com/

    validator problem #58332

    okasha
    Participant

    hello Mr Dimitar

    may you tell me an example of building rules dinamically

    thank you
    okasha

    validator problem #58348

    Dimitar
    Participant

    Hi okasha,

    Here is a suggestion:

    <!DOCTYPE html>
    <html lang="en">
    <head>
        <link rel="stylesheet" href="../../jqwidgets/styles/jqx.base.css" type="text/css" />
        <link rel="stylesheet" href="../../jqwidgets/styles/jqx.summer.css" type="text/css" />
        <script type="text/javascript" src="../../scripts/jquery-1.10.2.min.js"></script>
        <script type="text/javascript" src="../../jqwidgets/jqxcore.js"></script>
        <script type="text/javascript" src="../../jqwidgets/jqxvalidator.js"></script>
        <script type="text/javascript">
            $(document).ready(function () {
                var rules = new Array();
    
                $("#addInput1").click(function () {
                    $('#testForm').append('<input type="text" id="userInput" class="text-input" />');
                    rules.push({ input: '#userInput', message: 'The username should be more than 3 characters!', action: 'keyup', rule: 'minLength=3' });
                    $('#testForm').jqxValidator({ rules: rules });
                    $("#addInput2").css("display", "none");
                });
    
                $("#addInput2").click(function () {
                    $('#testForm').append('<input type="text" id="emailInput" class="text-input" />');
                    rules.push({ input: '#emailInput', message: 'Invalid e-mail!', action: 'keyup', rule: 'email' });
                    $('#testForm').jqxValidator({ rules: rules });
                    $("#addInput1").css("display", "none");
                });
            });
        </script>
    </head>
    <body>
        <form id="testForm" action="./">
        </form>
        <button id="addInput1">
            Add input 1</button>
        <button id="addInput2">
            Add input 2</button>
    </body>
    </html>

    Best Regards,
    Dimitar

    jQWidgets team
    http://www.jqwidgets.com/

Viewing 4 posts - 1 through 4 (of 4 total)

You must be logged in to reply to this topic.