动态客户端验证 [英] Dynamic Client side validation
本文介绍了动态客户端验证的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想按照xml读取进行动态客户端验证。我怎么能用动态代码呢?
I want to do dynamic client side validation as per xml read. how can i do that using dynamic code?
<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>
推荐答案
您可以创建如下函数:
函数setControlProperties(control,options)
{
control.required = options.mandatory;
control.maxlength = options.maxleght;
.....
}
读取xml并将其存储在Javascript中;
对于控件,将类型设置为Date,Decimal ......
为负载上的每个控件调用mehtod
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
这篇关于动态客户端验证的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文