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


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


6 Answers

New Answer


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


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


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


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


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


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