How to Validate dynamically created text box in HTML using Javascript
Here is the HTML code to create text boxes dynamically. It works properly in IE but not in fire fox and chrome. how to make this to work in all browsers.
And also how to validate the text boxes created dynamically.
<html>
<head>
<title>Multiple Text area Validation</title>
<script>
function addInputBox() {
var ni = document.getElementById('myDiv');
var ni1=document.getElementById('myDiv1');
var numi = document.myForm.inputboxlength;
var numi1=document.myForm.inputboxlength;
var num = parseInt(numi.value) +1;
var num1=parseInt(numi1.value)+1;
numi.value = num;
numi1.value=num1;
var newdiv = document.createElement('div');
var newdiv1=document.createElement('div');
newdiv.innerHTML = "<input type=\"text\" name=\"txt"+num +"\" />" ;
newdiv1.innerHTML="<input type=\"text\" name=\"txt1"+num1+"\"/>";
ni.appendChild(newdiv);
ni1.appendChild(newdiv1);
}
function reset()
{
var numi = document.myForm.inputboxlength;
numi.value=0;
}
</script>
</head>
<body onload="reset()">
<form name="myForm" action="result.jsp" >
<p><input type='button' onclick='addInputBox()' value='Add'/></p>
<input type="hidden" name="inputboxlength" value="0" />
<!--<div id="myDiv"><div id="myDiv1"></div> </div> -->
<div id="mydiv"><div id="mydiv1"></div></div>
<input type="submit" value="Submit" >
</form>
</body>
</html>
View Answers
Ads
Related Tutorials/Questions & Answers:
Advertisements
how to print HTML using javascript or Jquery
how to print
HTML using javascript or Jquery is there any way to print a document(
created using Html and
javascript) without
using window.print, which works for all the browser specially chrome and firefox, I have used
How to check text in textbox using JavaScript
How to check
text in textbox
using JavaScript
How to check
text in textbox
using JavaScript
I have a form in
HTML that contains
text feilds... me.
JavaScript validation example to check
text in textfeild
<
Html form using JavaScript to display the table content
Html form
using JavaScript to display the table content HI There, Greetings,
I am new to this java and I need your assistance.
I have
created... want to write a
Html JavaScript coding to display the content from database
Select Box Validation in JavaScript
created one
JavaScript
in which one select
box is
created name "select your...Select
Box Validation in
JavaScript
In this section we will discuss about select
box validation in
JavaScript. Select
box allows you to create drop down list
JavaScript regex validate validate Zip.
JavaScript regex
validate validate Zip.
JavaScript regex
validate -
how to
validate Zip?
<html>
<head>
<title>Zip Code validation
using regex</title>
<script type="
text/
javascript">
Hide show HTML forms using javascript
Hide show
HTML forms
using javascript
How to hide a
HTML form in my application
using JavaScript?
HTML Code to create checkbox
<...;div id="yourDiv"> ...other forms... </div>
JavaScript function to hide
how to create a combo box in html
how to create a combo
box in html <tr>
<td>Number<span class=mandatory>*</span></td>
<td>
<select name... the following link:
HTML Combobox
how to display webservice response in a text box
how to display webservice response in a
text box Hallo,
i have
created a webservice and when i sended request to my webservice its sending proper response . the point is
how to dispaly the response values in a
text box usinj
populating text box using jsp code
populating
text box using jsp code Sir,
How to populate related values in a
text box after selecting value from drop down list
using JSP and mysql. I tried
using Ajax from your example. But for some browser it does not support