I want to add the jquery-form-validator to my customer's old CMS.
This jqery form validator requires to insert a class such as class="validate[required,custom[onlyLetter],length[0,100]]" to input.
<input class="validate[required,custom[onlyLetter],length[0,100]]" name="firstname" type="text" />
Since this is (old from '90) CMS, I need to add class by js like this.
var inputid = $(this).attr("id");
if(inputid=='navn'){
$(this).removeClass().addClass('validate[required,custom[onlyLetter],length[0,100]] text-input');
}else if(inputid=='e-post'){
$(this).removeClass().addClass('validate[required,custom[email]] text-input');
}else if (inputid=='telefon'){
$(this).removeClass().addClass('validate[required,custom[telephone]] text-input');
It add class to input tags as I wanted. However when I add class by js, it does not work. I assume it is because of event delegation.
Can anyone help me how to do in this situation please?
Thanks in advance.