Is this best practice way to send messages to the user?
Update: This has been changed to a simple function call.
/**
*Message - Sends message to the .innerHTML of an element
*/
var Message = ( function ()
{
var messages =
{
name: 'Please enter a valid name',
email: 'Please enter a valid email',
email_s: 'Please enter a valid email.',
pass: 'Please enter password, 6-40 characters',
url: 'Please enter a valid url',
title: 'Please enter a valid title',
tweet: 'Please enter a valid tweet',
empty: 'Please complete all fields',
same: 'Please make emails equal',
taken: 'Sorry, that email is taken',
validate: 'Please contact <a class="d" href="mailto:[email protected]">support</a> to reset your password',
};
var MessageInternal = function (element)
{
this.element = element;
};
MessageInternal.prototype.display = function( type )
{
this.element.innerHTML = messages[ type ];
};
return MessageInternal;
} () );