Quote:
|
i had to make myself get into the habbit of doing id's in inputs wether i needed them or not, because i do use them quite a bit in js for validation of input and it is easier to have them in there...
|
There is never any reason to use IDs for input validation.
Compare this code (just showing the code needed to access four form fields, no validation):
Code:
var fld1 = document.getElementById("field1");
var fld2 = document.getElementById("field2");
var fld3 = document.getElementById("field3");
var fld4 = document.getElementById("field4");
versus this:
Code:
var form = document.getElementById("myForm");
var fld1 = form.field1;
var fld2 = form.field2;
var fld3 = form.field3;
var fld4 = form.field4;
Using the form and field names produces shorter code *and* faster code.
What's the excuse for using IDs?