Backend doctype script not executing

I am following the following tutorial

I edited the with validation code as mentioned in the tutorial.
I entered the data in a way that should throw the message in the script and save.
But when i submit the librarymembership record, the script is not executing ie., the message is not showing up.