/////////////////////html
//////////JS
<asp:TextBox ID="TxtUserName"
OnTextChanged="Txtuser_TextChanged"
CssClass="form-control"
runat="server"
AutoPostBack="True"></asp:TextBox>
<asp:RequiredFieldValidator ID="RFVTxtUserName" runat="server" ControlToValidate
= "TxtUserName" Display="Dynamic"
ValidationGroup="ValReg"/>
//////////JS
<script type="text/javascript">
function Validate(ValGrp) {
var FLAG;
debugger;
if (Page_Validators.length > 0) {
for (var
i = 0; i < Page_Validators.length; i++) {
var val = Page_Validators[i];
var ctrl =
document.getElementById(val.controltovalidate); //Validate
if (ctrl != null
&& ctrl.style != null) {
if (ctrl.value == ""
&& (ctrl.getAttribute('style') != 'display: none;') && (ctrl.getAttribute('style') != 'border: 1px
solid red; display: none;')) {
if (Page_Validators[i].validationGroup == ValGrp ) {
ctrl.style = "border: 1px solid red";
FLAG = 1;
}
}
else {
ctrl.style.borderColor = '';
}
}
}
}
if (FLAG == 1) {
return false;
}
else {
return true;
}
}
</Script>
No comments:
Post a Comment