Bypass HTML “required” attribute when submitting [duplicate]

No JavaScript, no second form needed, and the validation can stay: For exactly this use case the HTML5 spec has designed the formnovalidate attribute for submit elements (like <input type=submit>), as one of the attributes for form submission: The formnovalidate attribute can be used to make submit buttons that do not trigger the constraint validation. … Read more

Dynamically enable or disable RequiredFieldValidator based on value of DropDownList

You can do this with JavaScript like this: ValidatorEnable(RequiredFieldValidatorId, false); Then have your drop down list use the onchange event (I’d suggest using jQuery) $(“#<%=dropDownList.ClientID %>”).change(function(){ var val = $(this).val(); var skip = null; if (val == 1) skip = “workPhoneValidator”; else if (val == 2) skip = “cellPhoneValidator”; …. // by popular demand… var … Read more

How to add a RequiredFieldValidator to DropDownList control?

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 that validation will succeed if any other value than the 1 set in … Read more

Conditionally required property using data annotations

RequiredIf validation attribute I’ve written a RequiredIfAttribute that requires a particular property value when a different property has a certain value (what you require) or when a different property has anything but a specific value. This is the code that may help: /// <summary> /// Provides conditional validation based on related property value. /// </summary> … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)