JS if & else not working..!๐Ÿ˜• | Sololearn: Learn to code for FREE!

+6

JS if & else not working..!๐Ÿ˜•

See JS code, after I click the Submit button if I have not filled anything in the input field, it gives an alert.....but even if I write something in the input field, it even then gives an alert......is there any fault in the JS code, please tell me https://code.sololearn.com/W0e908sXyZjU/?ref=app

10/14/2021 6:11:45 AM

Parth

6 Answers

New Answer

+5

var badgeName = $("#badgeName"); That line references the object, and not the string(value) inside that object.

+5

Hi bro I'll start again with the JS and explain you, I don't master jquery.

+4

Line 7: if (badgeName.length < 0) Should've been if (badgeName.length > 0)

+4

Ipang but it's still not working๐Ÿ˜•

+3

Arturop perfect, now it's working๐Ÿ˜ƒ Thankyou soooooooooooooooo much ๐Ÿ˜„

+2

Faxel here is the JS code https://code.sololearn.com/W40ZdN8ePU3m/?ref=app