Yeah it is necessary to specify the source of the script you use from a third party website. Although w3schools does not seem to accuse people of stealing their contents, its still not a good habit to develop, especially if you become so used to not give credits for what you take.
Also keep in mind that w3schools is actually not a very good tutorial site, at least from a professional point of view. Check out tutorialspoints.com if you wish to improve further:
http://www.tutorialspoint.com/