FACG2 / twitter

0 stars 3 forks source link

Js shouldn't assume the order of html elements #42

Open mantagen opened 7 years ago

mantagen commented 7 years ago

var signupNoteDiv = document.getElementsByClassName('errNote')[1]; It might be that your html switches the order of "login" and "signup", then your js wouldn't work any more...

https://github.com/FACG2/twitter/blob/master/public/js/validation.js#L12

Walidmash commented 7 years ago

so you we need to add id for each input to reach it, right?

mantagen commented 7 years ago

@Walidmash You could use an id or a custom data attribute. https://developer.mozilla.org/en-US/docs/Learn/HTML/Howto/Use_data_attributes

Eg. data-validation='password' and apply validations that way...