Honestly, I don't like your code at all...
For the images function... You don't need loop, because you know the you need the image with Id==2
Anyway I did some changes, check if it works ok
Code:
<html>
<head>
<script language="javascript">
//Main Function Caller
function caller() {
//Calling the findimage function
findimage();
findcontrol();
//End of the Caller function
}
//Start of the findimage function
function findimage() {
var images = document.getElementById("2");
//Start of the For Loop (findimage function)
for(var counter = 0; counter < 5; counter++) {
if(counter == 2)
{ images = document.getElementById(counter);
alert("Found Image #3.. It's source is: " + images.src);
}
}
//End of the For Loop (findimage function)
//Calling the findcontrol Function
}
//End of the findimage function
//Start of the findcontrol function
function findcontrol() {
var textform = document.myform;
var formlength = document.myform.length;
//Start of the For Loop (findcontrol function)
for (var idform = 0; idform < formlength; idform++) {
if(textform[idform].type=="text")
{
if (textform[idform].value=="")
{
alert("Sorry! You have not filled in number " + [idform] + " text field");
}
}
}
//End of the For Loop (findcontrol function)
//End of the findcontrol function
}
</script>
</head>
<body>
<form name="myform">
<label>First Name</label><br /><input type="text" id="textone" />
<br />
<label>Last Name</label><br /><input type="text" id="texttwo" />
<br />
<label>Address</label><br /><input type="text" id="textthree" />
<br />
<label>Email Address</label><br /><input type="text" id="textfour" />
<p>
<img src="images/1.gif" id="0" />
<img src="images/2.gif" id="1" />
<img src="images/3.gif" id="2" />
<img src="images/4.gif" id="3" />
<img src="images/5.gif" id="4" />
</p>
<input type="button" value="Click Me" onclick="caller()" />
<input type="reset" value="Reset" />
</form>
</body>
</html>