Folks,
I have two text boxes in my html. I wanted to compare their values using coffee script. Although I have googled about it, and I am kind of sure that I am doing what is expected to do but still I see a strange behavior.
Thing is :
Lets say, I have two text boxes with id as "title" and "author". Along with that, I have a button which onclick triggers the coffee script function.
My coffee script function looks as:
check_fields = ->
elem_book_title = $("#title").val()
elem_book_author = $("#author").val()
alert(elem_book_title)
alert(elem_book_author)
if not elem_book_title?
alert("title is null")
else if not elem_book_author?
alert("author is null")
else
alert("both are ok")
Situation is, If I enter something only in my "title" textbox, it should alert me that "author is null". Right? But surprisingly, it alerts me that "both are ok".. Expected? Or I missed something?