requiredfieldvalidator

RequiredFieldValidator with ValidationGroup doesn't validate

谁说胖子不能爱 提交于 2019-12-04 11:00:38
Here's my markup: Name: <asp:TextBox ID="txtNewName" runat="server" ValidationGroup="NewDepartmentValidationGroup" /> <asp:RequiredFieldValidator ID="vldtxtNewName" runat="server" ControlToValidate="txtNewName" ErrorMessage="Required Field" /><br /> Description: <asp:TextBox ID="txtNewDescription" runat="server" ValidationGroup="NewDepartmentValidationGroup"/> <asp:RequiredFieldValidator ID="vldtxtNewDescription" runat="server" ControlToValidate="txtNewDescription" ErrorMessage="Required Field" /><br /> <asp:Button ID="cmdCreate" runat="server" Text="Create" ValidationGroup=

How to make a property required based on multiple condition?

假如想象 提交于 2019-12-04 05:33:40
I have a list of Pair of radio buttons (Yes/No): Q1.(Y)(N) Q2.(Y)(N) Q3.(Y)(N) Q4.(Y)(N) and I have one property in my model public string MedicalExplanation { get; set; } My goal is to make Explanation required if any of the radio button has been set to true. My first try was to use [Required] but it does not handle conditions. Then I decided to use third party tool like MVC Foolproof Validation I used it like this: [RequiredIf("Q1", true, ErrorMessage = "You must explain any \"Yes\" answers!")] Now the problem is I don't know how to make it required if any of the other Q2, Q3, Q4 is checked.

Require validation only if the field is visible

僤鯓⒐⒋嵵緔 提交于 2019-12-03 11:53:19
问题 I am using the [Required] attribute for the client-side validation in ASP.NET MVC 3. The class looks as: public class User { [Required(ErrorMessage = "First Name is required")] public string FirstName { get; set; } } I want the field FirstName to be validated only if it's visible, which will be shown only on certain conditions. How can I do that? I have used the following, but still it looks to validate for the required field of that hidden field. $('#registerForm').validate({ ignore: ":not(

Require validation only if the field is visible

北城以北 提交于 2019-12-03 01:24:44
I am using the [Required] attribute for the client-side validation in ASP.NET MVC 3. The class looks as: public class User { [Required(ErrorMessage = "First Name is required")] public string FirstName { get; set; } } I want the field FirstName to be validated only if it's visible, which will be shown only on certain conditions. How can I do that? I have used the following, but still it looks to validate for the required field of that hidden field. $('#registerForm').validate({ ignore: ":not(:visible)" }); Prasad With some useful hints from @Josiah, i am able to get to my requirement. Add the

How to place a required field validator inside a GridView TextBox

≡放荡痞女 提交于 2019-12-02 21:12:15
问题 I have a GridView with some TemplateField items containing TextBox controls. I would like to add a required field validator on it. This is my code: <asp:TemplateField HeaderText="vid"> <EditItemTemplate> <asp:TextBox ID="txtvid" runat="server" Width="150px" Text='<%# Bind("vid") %>'> </asp:TextBox> </EditItemTemplate> <ItemTemplate> <asp:Label ID="lblvid" runat="server" Text='<%# Bind("vid") %>'> </asp:Label> </ItemTemplate> </asp:TemplateField> How do I place a required field validator on

Dynamically created requiredfieldvalidator bypasses client side validation

耗尽温柔 提交于 2019-12-02 19:09:54
问题 I am trying to add a required field validator to my page at runtime. Nothing fancy there: <form id="form1" runat="server"> <asp:ScriptManager ID="ScriptManager1" runat="server"> </asp:ScriptManager> <asp:TextBox ID="TextBox1" runat="server"></asp:TextBox> <asp:Button ID="Button1" runat="server" Text="Button" /> <asp:ValidationSummary ID="ValidationSummary1" runat="server" ShowMessageBox="True" ShowSummary="False" /> </form> and @ codebehind protected void Page_Init(object sender, EventArgs e)

Making email field required in php [closed]

▼魔方 西西 提交于 2019-12-02 13:42:11
I have a php script for the capture of a name and email address for a mailing list. If possible could someone please offer some adivce on how to make the email and name fields as required, so user is forced to input their name and email into form fields. Again much appreciated for any help !! The following is the php code being used for the form <?php $sendTo = "info@mail.com"; $subject = "website email enquiry"; $headers = "From: " . $_POST["firstName"] ." ". $_POST["lastname"] . "<" . $_POST["email"] .">\r\n"; $headers .= "Reply-To: " . $_POST["email"] . "\r\n"; $headers .= "Return-path: " .

RequiredFieldValidator Working Oddly in Update Panel

断了今生、忘了曾经 提交于 2019-12-02 11:41:59
问题 I've got an update panel with a textbox and a requiredfieldvalidator and a couple of buttons. On pageload, you see a label and a button. On button press, the textbox and validator display (along with the other button). The basic change in display works fine. However, my validator (which is set to be dynamic) displays its error message, even if the textbox is populated. Provided that the textbox is populated, pressing the submit button does actually work, but there's obviously something not

How to place a required field validator inside a GridView TextBox

别说谁变了你拦得住时间么 提交于 2019-12-02 10:14:07
I have a GridView with some TemplateField items containing TextBox controls. I would like to add a required field validator on it. This is my code: <asp:TemplateField HeaderText="vid"> <EditItemTemplate> <asp:TextBox ID="txtvid" runat="server" Width="150px" Text='<%# Bind("vid") %>'> </asp:TextBox> </EditItemTemplate> <ItemTemplate> <asp:Label ID="lblvid" runat="server" Text='<%# Bind("vid") %>'> </asp:Label> </ItemTemplate> </asp:TemplateField> How do I place a required field validator on txtvid ? In the Edit template, add a RequiredFieldValidator like this: <EditItemTemplate> <asp:TextBox ID

Dynamically created requiredfieldvalidator bypasses client side validation

时光总嘲笑我的痴心妄想 提交于 2019-12-02 07:44:39
I am trying to add a required field validator to my page at runtime. Nothing fancy there: <form id="form1" runat="server"> <asp:ScriptManager ID="ScriptManager1" runat="server"> </asp:ScriptManager> <asp:TextBox ID="TextBox1" runat="server"></asp:TextBox> <asp:Button ID="Button1" runat="server" Text="Button" /> <asp:ValidationSummary ID="ValidationSummary1" runat="server" ShowMessageBox="True" ShowSummary="False" /> </form> and @ codebehind protected void Page_Init(object sender, EventArgs e) { RequiredFieldValidator theValid = new RequiredFieldValidator(); theValid.ID = "0000" + "RFV";