We help IT Professionals succeed at work.

attaching function to a dynamix text box.

164 Views
Last Modified: 2010-04-16
I have a situation where I have created a form that adds and deletes rows with text boxes in them. I need to force that two of the text boxes on each line only allow certain characters. So for instance one text box can only have an an integer and the textbox next to it can only have dollar amounts. They need to validate when the user loses focus on the box.

Since the cells are dynamic, I am not sure how to include a function call when I create each cell and text box with the following code:

var cellRight = row.insertCell(0);
          var el = document.createElement('input');
              cellRight.style.backgroundColor = "#FFFFFF";
          el.type = 'text';    
          el.name = 'manuf' + iteration;    
          el.id = 'manuf' + iteration;
// I want to put a call to a javascript function here.
              el.style.textTransform = "uppercase";
          cellRight.appendChild(el);

Any thoughts out there.
Comment
Watch Question

have you tried this?
var cellRight = row.insertCell(0);
var el = document.createElement('input');
cellRight.style.backgroundColor = "#FFFFFF";
el.type = 'text';    
el.name = 'manuf' + iteration;    
el.id = 'manuf' + iteration;
 
// I want to put a call to a javascript function here.
el.onBlur = checkValue(this);
 
el.style.textTransform = "uppercase";
cellRight.appendChild(el);

Open in new window

Author

Commented:
Yeah that didnt quite do it. Actually breaks the creation of the row.
This one is on us!
(Get your first solution completely free - no credit card required)
UNLOCK SOLUTION
Unlock the solution to this question.
Join our community and discover your potential

Experts Exchange is the only place where you can interact directly with leading experts in the technology field. Become a member today and access the collective knowledge of thousands of technology experts.

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

OR

Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.