User Rating: 2 / 5

Star ActiveStar ActiveStar InactiveStar InactiveStar Inactive
 

on our XML layout, we need to write a jQuery code to set fields to numbers only

file structure:

 

joomla/administrator/components/com_helloworld/views/hello/tmpl/default.php

 

in order to set specific field to numbers only

insert this code on your script above the tag <table>

 

jQuery(document).ready(function() {
                jQuery('#field_id').number(true, 0);
});

 

The code above will set the field that has the same field_id which you call on your jQuery

 

if you want to set more field to insert numbers only, create the same class name of every field you want to set.. and on your script, code this below

 

jQuery(document).ready(function() {
                jQuery('table').find('input.classname').number(true, 2);
});

 

the code above will find all field that has class="classname" and it will be set to numbers only