How to use multiple Validation on a text box that is Dynamic

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • syedshaffee
    New Member
    • Jan 2012
    • 91

    How to use multiple Validation on a text box that is Dynamic

    Guyz,
    I have a problem here is the code doesn't' work Please help
    Code:
    function validateFormMultiple(theForm)
    {
    for (var i=0; theForm.same.checked; i++){
    if (theForm.same[i].checked ){
    if (theForm.Date[i].value == "") {
    			alert("Please Enter the Date.");
    			theForm.Date[i].focus();
    			return false;
    		}
    	
    		if (theForm.Comments[i].value == "") {
    			alert("Please select the Inspection Date.");
    			theForm.Comments[i].focus();
    			return false;
    		}
    		
    		theForm.EditType.value="Add";
    		return true;
    		}
    		else{
    		alert("Please Select Asset");
    	 }
       }
     }
    is something wrong please help
  • Dormilich
    Recognized Expert Expert
    • Aug 2008
    • 8694

    #2
    it’s line #3. line #4 indicates that theForm.same is a collection of elements and hence theForm.same cannot have a checked property.

    besides that this value is not suited in a for() loop, either the loop never starts (.checked is false) or it goes in an infinite loop (.checked is true). contrary if you check each element for its checked status, the loop will quit on the first time checked is false and no matter how many elements after that are true, they will not be evaluated.

    Comment

    • syedshaffee
      New Member
      • Jan 2012
      • 91

      #3
      Can U Suggest me how to Pull this Of

      Comment

      • Dormilich
        Recognized Expert Expert
        • Aug 2008
        • 8694

        #4
        that depends on what you want to do.

        Comment

        • syedshaffee
          New Member
          • Jan 2012
          • 91

          #5
          I want to validate very line item on an HTML table that is dynamically generated having in check box and two input fields
          if any of the field blank and which is checked.

          Comment

          Working...