How can I be sure that at least one of FatherName
or AncestorName
Is filled?
How can I manage that in
MyEntity.cs
since I shouldn't use[Required]
annotation for both of them?[Required] public string FatherName { get; set; } [Required] public string AncestorName { get; set; }
How can I manage it in UI?
Now I have a class for required inputs in UI. On each '.required-input'
elements change
, jQuery will check the elements with '.required-input'
class are filled or not, and then the submit button will be enabled/disabled.
Also all required elements have a *
sign.
$('#create').prop("disabled", true);
$(document).on('change', '.required-input', function() {
var requiredInputsAreFilled = true;
$('.required-input').each(function() {
if (!$(this).val()) {
requiredInputsAreFilled = false;
return false;
}
});
if (requiredInputsAreFilled) {
$('#create').prop("disabled", false);
} else {
$('#create').prop("disabled", true);
}
}).change();