I wanted to restrict input to integer field to 8 digits only. if user enters less than 8 digits, i need a pop up saying an error message. Is it possible with Appgini?. My version is 5.30 rev 628.
any help appreciated
Is it possible to restrict number of digit of integer field?
Re: Is it possible to restrict number of digit of integer field?
You can do this by adding a javascript validation rule to the detail view. In the 'hooks' folder, create a file named 'tablename-dv.js' if it's not already there (where tablename is the name of the concerned table), and add your validation code inside it. Here is an example:
Replace 'fieldname' in the above code with the actual field name.
Code: Select all
$j('#update, #insert').click(function(){
if($j('#fieldname').val().length != 8){
modal_window({
message: '<div class="alert alert-danger">Fieldname must be 8 digits long.</div>',
title: "Error in fieldname",
close: function(){
$j('#fieldname').focus();
$j('#fieldname').parents('.form-group').addClass('has-error');
}
});
return false;
};
return true;
});
AppGini plugins to add more power to your apps:
- DataTalk is an innovative AppGini plugin based on ChatGPT that allows you to interact with your AppGini database using natural language questions, without writing any SQL. Check the demo video
- Mass Update plugin: Update multiple records at once and improve your workflow efficiency.
- Check our other plugins and get a generous discount of up to 30% when buying 2 or more plugins.
Re: Is it possible to restrict number of digit of integer field?
Thanks ahmed
I found the following example under Magic files in Online help, which solved my problem
I found the following example under Magic files in Online help, which solved my problem
Code: Select all
document.observe('dom:loaded', function() {
$('score').observe('change', function() {
if(isNaN($F('score')) || $F('score') > 100 || $F('score') < 0){
alert('Score must be between 0 and 100!');
$('score').focus();
}
});
});