Foren

jquery validation in Liferay 7

Kiran R, geändert vor 6 Jahren.

jquery validation in Liferay 7

Junior Member Beiträge: 37 Beitrittsdatum: 23.10.13 Neueste Beiträge
Hi Team,

I have a requirement like on selecting upon a checkbox , i need to enable a button.Initially, button is disabled by default.
I have coded this using Jquery as below. I don't see this code in view source also.
Can i use this code as it is in liferay 7 or anything changes i need to?

Used: Liferay 7 GA4



<script>
<label for="agree">
<input id="agree" type="checkbox" value="agree" onclick="" v-model="checked"/>
I Agree to the Terms and Conditions </label>

<button type="button" disabled class="btn btn-ts pull-right" id="agreeBtn">
I Agree </button>

$(document).ready(function(){
$('#agree').on('click', function(e) {
alert("clicked")..
if ($(this).is(':checked')) {
$('#agreeBtn').removeAttr('disabled'); //enable input

} else {
$('#agreeBtn').attr('disabled', true); //disable input
}
}

});
});
thumbnail
Samuel Kong, geändert vor 6 Jahren.

RE: jquery validation in Liferay 7

Liferay Legend Beiträge: 1902 Beitrittsdatum: 10.03.08 Neueste Beiträge
You'll need to use the variable 'jQuery' instead of '$'

Side note: You should add a namespace to your variables. to avoid conflict with other elements on the page.
Kiran R, geändert vor 6 Jahren.

RE: jquery validation in Liferay 7 (Antwort)

Junior Member Beiträge: 37 Beitrittsdatum: 23.10.13 Neueste Beiträge
Thank you Samuel for replying my query.

It works now.