Click here to Skip to main content
15,886,664 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I want to do dynamic client side validation as per xml read. how can i do that using dynamic code?


XML
<Validate Type="ALPHANUMERIC">
       <RegEx />
       <Mandatory>true</Mandatory>
       <MinLength>1</MinLength>
       <MaxLength>50</MaxLength>
       <Event>LOSTFOCUS</Event>
       <ColumnName>txtReportNo</ColumnName>
     </Validate>

 <Validate Type="DATE">
       <RegEx />
       <Mandatory>true</Mandatory>
       <Format>1</Format>
       <Event>LOSTFOCUS</Event>
       <MinValue />
       <MaxValue />
       <ColumnName>dtpReportDate</ColumnName>
     </Validate>

<Validate Type="DECIMAL">
       <RegEx />
       <Mandatory>true</Mandatory>
       <MinLength>1</MinLength>
       <MaxLength>13</MaxLength>
       <MinValue>1</MinValue>
       <MaxValue />
       <Precision>4</Precision>
       <Event>KEYPRESS</Event>
       <ColumnName>colDPipeDia</ColumnName>
     </Validate>
Posted
Updated 8-Apr-14 23:13pm
v2

1 solution

You can create a function as below:
function setControlProperties(control, options)
{
control.required = options.mandatory;
control.maxlength = options.maxleght;
.....
}

Read the xml and store it in the Javascript;
For the controls set the type as Date, Decimal...
Call the mehtod for each control on the load
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900