requiredfieldvalidator

Conditional RequiredFieldValidator inside of a repeater

孤街醉人 提交于 2019-12-25 05:13:13
问题 I have a repeater that holds a Radio button list, a textbox and a requiredfieldvalidator control. The Radiobuttonlist holds the following: Meets (Value M) Above (Value A) Below (Value B) N/A (Value(N/A) The textbox is set to allow the user to input some justification for their answer, and the requiredfieldvalidator makes sure that the textbox is not empty, simple enough. However the scope has changed a bit and now the client wants the requiredfieldvalidator to fire ONLY if the answer is not

Make RequiredFieldValidator in aspx.cs (code behind) asp.net

流过昼夜 提交于 2019-12-24 14:26:59
问题 I have a TextBox where i add a number and at a buttonclick i create new textboxes depending on what number i put in my first TextBox. For example i put 5 in the TextBox and press button i get 5 new textboxes on my page. Now im trying to make a RequiredFieldValidator on all of this textboxes thats created but i can't get it to work. I have another button that makes an insert to my db and this values from all the new textboxes are required. Can someone take a look at my code to see if im on the

Required Field validator disappears on dropdownlist post back

拟墨画扇 提交于 2019-12-23 12:27:02
问题 I populate two dropdownlist in asp.net. Both are assigned to a required field validator. The codebehind is as below if (!Page.IsPostBack) { DataTable dt = new DataTable(); dt.Columns.Add("emp"); dt.Columns.Add("ename"); for (int i = 0; i < 5; i++) { DataRow dr = dt.NewRow(); dr["emp"] = (i + 1).ToString(); dr["ename"] = (i + 1).ToString(); dt.Rows.Add(dr); } ddlEmp.DataSource = dt; ddlEmp.DataTextField = "emp"; ddlEmp.DataValueField = "ename"; ddlEmp.DataBind(); ListItem l1 = new ListItem("-

Enable/disable RequiredValidator on client-side / CustomValidator not firing

a 夏天 提交于 2019-12-22 05:06:32
问题 I've got a drop-down where the user selects a Country. It is a required "field". Next to it, there is a textfield named State. If the user selects US, then the field State is required. If the user selects e.g. Sweden, the State is not required, since Sweden has no states. Example code: <asp:DropDownList runat="server" ID="Country"></asp:DropDownList> <asp:RequiredFieldValidator ControlToValidate="Country" runat="server" Display="Static" ErrorMessage="Required field" /> <asp:TextBox runat=

How to make a property required based on multiple condition?

北城余情 提交于 2019-12-21 12:02:17
问题 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

Making email field required in php [closed]

倾然丶 夕夏残阳落幕 提交于 2019-12-20 07:56:17
问题 Closed . This question needs to be more focused. It is not currently accepting answers. Want to improve this question? Update the question so it focuses on one problem only by editing this post. Closed 5 years ago . 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

RequiredFieldValidator have to click twice

大憨熊 提交于 2019-12-18 04:24:20
问题 I have run into the same problem as described here. Only the question is marked as answered with only an explanation as to why you may have to click twice when using a RequiredFieldValidator on input fields - once as the blur of a textbox(for example) will correct the validation and then again to actually post the form. I don't want to have to click a button twice! Does anyone know a solution or workaround to this? 回答1: You could add EnableClientScript=false to the validator. That prevents

How to add a RequiredFieldValidator to DropDownList control?

一世执手 提交于 2019-12-17 06:33:11
问题 I have a DropDownList binded with a SqlDataSource to display the values from the database. I am unable to validate using a RequiredFieldValidator . 回答1: For the most part you treat it as if you are validating any other kind of control but use the InitialValue property of the required field validator. <asp:RequiredFieldValidator ID="rfv1" runat="server" ControlToValidate="your-dropdownlist" InitialValue="Please select" ErrorMessage="Please select something" /> Basically what it's saying is

Handling RequiredFieldValidator inside of a User Control

孤街浪徒 提交于 2019-12-13 14:41:31
问题 I have a User Control which consists of a TextBox with a few extras, but for purposes of this example just assuming it's a plain TextBox will be sufficient. I am calling this User Control from a Web Form and would like to be able to use a RequiredFieldValidator that basically would function the same as if I used it on a TextBox on the web form. How do I configure my User Control to handle this? EDIT: DatePicker.ascx <asp:TextBox runat="server" ID="myControlTB"> DatePicker.ascx.cs

Using RequiredFieldValidator to check if at least one of the two textboxes has some text inside?

青春壹個敷衍的年華 提交于 2019-12-12 18:06:48
问题 I have two textboxes on my asp.net page and a submit button. How can I use a single or more RequiredFieldValidators to check if at least one of the two textboxes has some text inside on submit button click? 回答1: Along with two text boxes add a CustomValidator and call server side validation. <asp:TextBox ID="TextBox1" runat="server"></asp:TextBox> <br /> <asp:TextBox ID="TextBox2" runat="server"></asp:TextBox> <br /> <asp:CustomValidator ID="CustomValidator1" runat="server" ErrorMessage=