0
텍스트 상자가 비어 있지 않은 경우 RadioButton 필수 필드를 만들려면 어떻게해야합니까? 텍스트 상자에 값이있는 경우 텍스트 상자와 두 개의 라디오 버튼이있는 라디오 버튼 필수 입력란을 만들었습니다.RadioButton 용 필수 항목
텍스트 상자가 비어 있지 않은 경우 RadioButton 필수 필드를 만들려면 어떻게해야합니까? 텍스트 상자에 값이있는 경우 텍스트 상자와 두 개의 라디오 버튼이있는 라디오 버튼 필수 입력란을 만들었습니다.RadioButton 용 필수 항목
ASP.NET MVC의 모든 모델에 사용자 지정 유효성 검사 규칙을 추가 할 수 있습니다. 다음은 그 예이다 : 텍스트 상자하지 비어있는 경우
public class CoolArchTekModel : IValidatableObject {
public string SomeTextBox { get; set; }
public bool SomeRadioButton { get; set; }
public IEnumerable<ValidationResult> Validate(ValidationContext validationContext) {
if (string.IsNullOrEmpty(this.SomeTextBox) && !this.SomeRadioButton) {
yield return new ValidationResult("The radio button is required if the text box is empty!");
}
}
}
질문은 내가 라디오 버튼을 어떻게 강요하는 걸까된다 RequiredIf ("SomeTextBox가", "여기 무슨 말을"ErrorMessage가이 = "메시지")] – CoolArchTek