jqBootstrapValidation.js attr, translate data-validation-required-message from json file

Viewed 57

Hi there i'm translating my website in 4 languages, i've done everything ok but now i'm stuck on contact form working with jqBootstrapValidation.js. This is how the input field are first of my translate conversion.

<div class="form-group">
    <input type="text" class="form-control" placeholder="Your full name *" id="name" required data-validation-required-message="Please enter your full name.">
    <p class="help-block text-danger"></p>
</div>

I successfully translate everything, placeholder also, following my html and js code:

<div class="form-group">
    <input type="text" class="form-control" id="name" required>
    <p class="help-block text-danger"></p>
</div>

<script>
    $(document).ready(function(){
    getLanguage();
    $('#name').attr('placeholder', language.nameplaceholder);
    $('#name').attr('data-validation-required-message', language.namedata);
    });
</script>

and here json of Italian language

{
"nameplaceholder": "Il tuo Nominativo *",
"namedata": "Inserire il vostro nominativo."
}

all works great but i'm loosing my mind trying to cast data-validation-required-message. Any helps would be appreciated. Thanks in advance and sorry for my bad english.

0 Answers
Related