validation-controls

Why ValidatorValidate() validates all the RequiredFieldValidator controls on the page?

依然范特西╮ 提交于 2020-01-24 09:06:12
问题 In following code Why ValidatorValidate(v) validates all the RequiredFieldValidator controls on the page? It should execute only RequiredFieldValidator1 not RequiredFieldValidator2 . Here is code. <html xmlns="http://www.w3.org/1999/xhtml"> <head> <script type="text/javascript"> function check() { var v = document.getElementById("<%=RequiredFieldValidator1.ClientID%>"); ValidatorValidate(v); } </script> </head> <body> <form id="form1" runat="server"> <div> <asp:TextBox ID="TextBox1" runat=

Regular expression for validating UAE numbers

只谈情不闲聊 提交于 2020-01-16 18:40:41
问题 I need regex which validates UAE mobile phone number like +9710501234566 or +971 (050) (123 4566) Currently I am using ^(\+971[\s]{0,1}[\-]{0,1}[\s]{0,1}|[\s]{0,1}0)(5[056]{1})[\s]{0,1}[\-]{0,1}[\s]{0,1}[1-9]{1}[0-9]{6}$ Could you help me please? I'm not really good with regular expressions... 回答1: Try this: Regex regex = new Regex(@"^\+971(\d{10}|\s\(\d{3}\)\s\(\d{3}\s\d{4}\))$"); Basically, you check for +971 as is, then either for 10 digits right after that, or the pattern space - left

Error throws using ModelClientValidationRule in MVC 5?

心不动则不痛 提交于 2019-12-22 08:17:34
问题 I try to do the custom client side validation in MVC 5 Project. When I add the following code: public IEnumerable<ModelClientValidationRule> GetClientValidationRules(ModelMetadata metadata, ControllerContext context) { //Some Validation Here } I get the following error : The type name 'ModelClientValidationRule' could not be found. This type has been forwarded to assembly 'System.Web.WebPages, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35'. Consider adding a reference to

Asp.net Dynamic Validators don't work in Chrome or Safari

馋奶兔 提交于 2019-12-21 02:41:11
问题 Ok, I'm dynamically creating Asp.net validation controls and inserting them into an update panel. The validation works in IE and Firefox, but not in Chrome or Safari. Here is the aspx file. Don't ask why I'm not using a button server control... <asp:ScriptManager ID="ScriptManager1" runat="server" /> <div> <asp:Label ID="Label1" runat="server" Text="Label"></asp:Label> <asp:UpdatePanel ID="UpdatePanel1" UpdateMode="Always" runat="server"> <ContentTemplate> <asp:PlaceHolder ID="PlaceHolder1"

Error throws using ModelClientValidationRule in MVC 5?

折月煮酒 提交于 2019-12-05 12:40:10
I try to do the custom client side validation in MVC 5 Project. When I add the following code: public IEnumerable<ModelClientValidationRule> GetClientValidationRules(ModelMetadata metadata, ControllerContext context) { //Some Validation Here } I get the following error : The type name 'ModelClientValidationRule' could not be found. This type has been forwarded to assembly 'System.Web.WebPages, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35'. Consider adding a reference to that assembly. But when I check the web.config file, I am using WebPages version supported from 0.0

Asp.net Dynamic Validators don't work in Chrome or Safari

泪湿孤枕 提交于 2019-12-03 08:40:24
Ok, I'm dynamically creating Asp.net validation controls and inserting them into an update panel. The validation works in IE and Firefox, but not in Chrome or Safari. Here is the aspx file. Don't ask why I'm not using a button server control... <asp:ScriptManager ID="ScriptManager1" runat="server" /> <div> <asp:Label ID="Label1" runat="server" Text="Label"></asp:Label> <asp:UpdatePanel ID="UpdatePanel1" UpdateMode="Always" runat="server"> <ContentTemplate> <asp:PlaceHolder ID="PlaceHolder1" runat="server"></asp:PlaceHolder> <input id="Button1" type="button" value="submit" onclick='javascript

Hide redundant error message in ASP.Net ValidationSummary

这一生的挚爱 提交于 2019-12-02 19:26:01
问题 I have a asp.net page accepting two input values – Name and Address. Both of them are required fields. I have used required field validators and validation summary. When user does not enter both the values the error message if fired two times though the error message is redundant. I need to display only one error message even though there are two errors. How can we handle it using jQuery? How can we handle it using ASP.Net markup? Note : I initially thought that the validation control will be

Hide redundant error message in ASP.Net ValidationSummary

て烟熏妆下的殇ゞ 提交于 2019-12-02 12:50:10
I have a asp.net page accepting two input values – Name and Address. Both of them are required fields. I have used required field validators and validation summary. When user does not enter both the values the error message if fired two times though the error message is redundant. I need to display only one error message even though there are two errors. How can we handle it using jQuery? How can we handle it using ASP.Net markup? Note : I initially thought that the validation control will be emitting HTML while page load itself so that I can use "view source" and do jQuery on HTML elements.