jQuery UI Widgets › Forums › Plugins › Validator, Drag & Drop, Sortable › validator problem
This topic contains 3 replies, has 2 voices, and was last updated by Dimitar 10 years, 3 months ago.
-
Authorvalidator problem Posts
-
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 undefinedmay you help me please
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,
DimitarjQWidgets team
http://www.jqwidgets.com/hello Mr Dimitar
may you tell me an example of building rules dinamically
thank you
okashaHi 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,
DimitarjQWidgets team
http://www.jqwidgets.com/ -
AuthorPosts
You must be logged in to reply to this topic.