Skip to main content
Inspiring
October 17, 2011
Question

Validate Dynamically Generated Form Fields

  • October 17, 2011
  • 2 replies
  • 916 views

Hello, I am having difficulty in validating some text boxes I dynamically generated using javascript.

I have done the below which is not working..... giving errors of undefined or is null

var i=rowNum;//value of the integer giving the form field a unique name

var thefield =(eval(document.getElementById('xxxx_'+i).value));

if (thefield =="")

{

alert("xxxxxxxxxxxxx");

}

This is not working. Any one has example of validating dynamically generated form fields?

    This topic has been closed for replies.

    2 replies

    Legend
    October 17, 2011

    Check out jquery and the validation plug-in by Jörn Zaefferer: http://plugins.jquery.com/project/validate

    It'll simplify your life!

    Inspiring
    October 17, 2011

    If this were my problem, I'd do something like this:

    alert("good start");

    var i = 1;

    alert("i is " + i);

    var thefield =(eval(document.getElementById('xxxx_'+i).value));

    alert("the fields is " + thefield+ " some more text");

    That would help me isolate the problem.