I have a function that contains messages for form field validation. However I would like to have default messages but also have the possibility to add custom messages later on from a different function (on the fly). I have tried something using php and extending a class and adding more messages and than building the javascript but I'm not really happy doing it this way.
function msg_text(fieldV){
msg = {
"required":{
"alertText":"* This field is required"
},
"length":{
"alertText":"* minimum 6 characters "
},
"numeric":{
"alertText":"numbers and * only<br />minimum 3 characters"
},
"email":{
"alertText":"* Invalid email address"
},
"no_space":{
"alertText":"* Is Required <br /> * Space not allowed"
}
}
return msg[fieldV].alertText; //returns alert message
}