I just started learnning javascript loops, and I created a simple first loop which doesn't work and I can't figure out why,
please try to keep it simple for now as I'm just a beginner, try to correct it by doing simple things if possible and if not just tell me and I will study some more about it,
the code is supposed to send an alert if the value of a input text has been left empty
<form name="myForm" runat="server" onsubmit="return myFunction()">
<div>
First name<input type="text" id="firstname" name="fname" />
<input type="submit" value="Submit" />
</div>
</form>
<script>
function myFunction() {
var x = document.forms["myForm"]["fname"].value;
var i = x.length;
for (var i = x.length; i = 0; i++) {
alert("asfasfas");
}
}
</script>
What did I do wrong?