내 응용 프로그램에 문제가 있습니다 (here). 응용 프로그램을 열 때 아래에 나타납니다 "열기 그리드"를 선택 옵션 4. 버튼 A, B, C 및 D를 클릭내 경고를이 방법으로 표시하고 싶습니다.
: 다음 단계를 따르십시오.
Number of Answers 텍스트 상자에 숫자 1을 입력 한 다음 A, B, C 또는 D 중에서 1 버튼을 클릭합니다 (선택한 단추가 녹색으로 바뀝니다). 작업을 마친 후 "질문 추가"버튼을 두 번 클릭하십시오.
위에서 볼 수 있듯이 입력 한 세부 정보는 아래 2 행에 표시됩니다. 첫 번째 새 행에서 "Number of Answers"열 아래의 텍스트 상자에 숫자 1을 0으로 변경하고 두 번째 행에서 Answers 텍스트 상자의 수를 1에서 2로 변경합니다. 이제 "Submit Details "버튼을 클릭하십시오.
"필요한 금액보다 적은 답변을 선택하셨습니다."라는 경고가 표시되어야합니다. "필요한 금액보다 더 많은 답변을 선택하셨습니다"라고 명시되어 있습니다. 이것은 첫 번째 행에서와 똑같은데, 하나의 응답이 선택되어 있지만 텍스트 상자에는 0 개의 대답이 필요하며 두 번째 행에는 하나의 대답이 선택되어 있지만 텍스트 상자에는 2 개의 답변이 필요하다고 나와 있습니다.
내 질문 :
이 두 행에 경고 모두 메시지를 보여주는를 제외하고, 내가 원하는 것을 먼저 첫 번째 행의 오류를 보여주는 경고를 보여줄 것입니다하지만 내 질문은 무엇입니까. 사용자가 첫 번째 행에서 오류를 정렬 한 후 두 번째 행에 오류가있는 경우 사용자가 "세부 정보 제출"버튼을 다시 클릭하면 두 번째 행에 오류 메시지가 표시됩니다.
질문 1에 오류를 수정하십시오 : "당신은 필요한 양보다 적은 답을 선택"
나는 경고가 예를 들어 첫 번째 행에 대해 다음과 같이 표시 할.
질문 2에서 오류를 수정하십시오 : 두 번째 행에 대한 경고에 대한
나는이 원하는 "당신은 필요한 양보다 더 많은 답변을 선택했습니다." 그렇지 않은 경우, 희망이, 의미가function validation() {
alertValidation= "";
// Note, this is just so it's declared...
$(".numberAnswerTxtRow").each(function() {
var currenttotal = $(this).closest('.optionAndAnswer').find('.answerBtnsOn') .length;
if (!this.value) {
alertValidation += "\nPlease Enter in the Number of Answers you Require for this question\n";
}
else if (currenttotal > $(this).val()){
alertValidation += "\nYou have selected more answers than the required amount\n";
}
else if (currenttotal < $(this).val()) {
alertValidation += "\nYou have selected less answers than the required amount\n";
}
});
if(alertValidation != "")
{
alert(alertValidation);
return false;
}
: 아래
는 관련 유효성 검사 코드 (내가 변수가 잘못 생각하는 문제가 VAR의 상황이라고 생각하지만 확실하지 않다)이다 제발 저에게 말 해주세요.function validation() {
$(".textAreaQuestion").each(function() {
alertValidation= "";
if (!this.value || this.value.length < 5) {
alertValidation += "\nYou have not entered a valid Question\n";
}
if(alertValidation != "")
{
alert(alertValidation);
return false;
}
});
$(".numberAnswerTxtRow").each(function() {
alertValidation= "";
var currenttotal = $(this).closest('.optionAndAnswer').find('.answerBtnsOn') .length;
if (!this.value) {
alertValidation += "\nPlease Enter in the Number of Answers you Require for this question\n";
}
else if (currenttotal > $(this).val()){
alertValidation += "\nYou have selected more answers than the required amount\n";
}
else if (currenttotal < $(this).val()) {
alertValidation += "\nYou have selected less answers than the required amount\n";
}
if(alertValidation != "")
{
alert(alertValidation);
return false;
}
});
return true;
}
죄송합니다. 저는이 답변을 보지 않았습니다. 나는 이것을 테스트했으며 이것이 아주 좋은 해결책 인 것처럼 보인다. 최선의 답변 :) – user1180490