Form validation question | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 1

Form validation question

So I just want to be clear here, so it's not possible to write multiple "if" statements like in this code, or is there a way to manipulate it? https://code.sololearn.com/WJGjUpqbUCuX/?ref=app

14th Aug 2020, 5:12 PM
Iloka Nadia
Iloka Nadia - avatar
3 Answers
+ 4
my approach to this will be first put required attribute to field that should not be blank. by doing so you dont need to check if they are empty https://code.sololearn.com/WieiQzw3D5Y4/?ref=app
14th Aug 2020, 5:29 PM
Taste
Taste - avatar
14th Aug 2020, 5:38 PM
Divya Mohan
Divya Mohan - avatar
+ 1
You can do this btw if (n1.value != '' && n2.value != '' && n1.value == n2.value) But it's better to follow Tastes approach
14th Aug 2020, 5:42 PM
Anis
Anis - avatar