2014-06-19 2 views
0

aspx 페이지와 CS 코드가 있습니다. YES와 NO 두 개의 라디오 버튼이 있습니다. 예를 선택하면 텍스트 상자가 표시되고 아니오이면 텍스트 상자가 보이지 않습니다. 라디오 버튼을 체크했을 때 텍스트 상자에 값을 넣지 않았을 때. 유효성 검사 오류가 발생하지 않습니다. CS 코드를 통해 유효성 검사를 처리하고 있습니다. js 바이올린을 참조하십시오.라디오 버튼에 공란 메시지가 표시되지 않음

JS 바이올린 : - "http://jsfiddle.net/BaxJe/"

또한 참조 용 버튼 클릭 코드를 참조하십시오 -

protected void btnSubmit_Click(object sender, EventArgs e) 
{ 
    SendMail(); 

    if (Page.IsValid) 
    { 
     if (radiobtnIsCustomer.Checked && txt_custId.Text == string.Empty) 
     { 
      div_errorMsg.InnerText = "Please enter your Customer Id."; 
      return; 
     } 

    } 
    if (!CaptchaControl1.IsValid) 
    { 
     lblCaptchaError.Text = "Invalid Captcha"; 
    } 

    Response.Redirect("ThankYou_AgriBusiness.html"); 
    Customer newCustomer = new Customer(); 
    newCustomer.IsExistingCustomer = radiobtnIsCustomer.Checked; 
    newCustomer.ExistingCustomerId = txt_custId.Text; 
} 

나는 stucked 얻고 어디 수 있어요 그래서 나, 알려 주시기 바랍니다 왜 내 검증 메시지가 오지 않는지 탐지하십시오.

감사

답변

0

나는 그것 때문에 aspx 페이지 아마도 jsFiddle에 문제가 있어요. 하지만 그 대신

"txt_custId.Text == String.Empty로"

의 나는 "String.IsNullOrEmpty (txt_custId.Text)"

+0

(radiobtnIsCustomer.Checked && String.IsNullOrEmpty (txt_custId을

을 시도 할 것입니다. 텍스트)) ?? – user3751568

+0

작동하지 않아 양식이 아직 제출 중입니다. – user3751568

+0

어둠 속에서 약간의 총알이 터지지 만 나는 Page를 믿습니다 .Valid가 충족되지 않아서 텍스트 상자가 비어 있는지 확인하지도 않습니다. 나는 "if (page.isvalid)"줄 위에 "Page.Validate()"줄을 넣거나 "causesValidation"단추를 true로 설정하여 유효성 검사를 먼저 수행해야한다고 생각합니다. – DasBeasto

관련 문제