0

I'm trying to validate form array element below but getting error. I wonder if it is set as an array because other normal elements are being validated without a problem.

Thanks in advance

ERROR

TypeError: document.formABC.textQualificationSet is undefined

JS

var textQualSubject = document.formABC.textQualificationSet[0]["Qual Subject"].value;

    if(textQualSubject == ""){
        alert("ERROR: Please enter at least first Qualification Subject");
        return false;
    }

HTML

<input type="text" name="textQualificationSet[0][Qual Subject]" value="" />
1
  • Have you looked at a validation library? parsleyjs.org/documentation.html Your users and any developer looking at this after you will thank you! Commented May 29, 2013 at 8:45

1 Answer 1

2

you are doing it wrong it, must be like this

document.getElementsByName('textQualificationSet[0][Qual Subject]')[0].value;

Reference

https://developer.mozilla.org/en-US/docs/Web/API/document.getElementsByName

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.