How can i restriction the filed value by using client script.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-14-2019 03:09 AM
Hi all,
I have requirement, can I restrict the field value by using client script.
thanks in advance.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-14-2019 03:18 AM
Can you elaborate a bit on your requirement? What field value you wanna restrict and to which values?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-14-2019 04:48 AM
Hi
I am trying to restrict the filed values by using configure dictionary, but it is not allow because all ready some records is their. thus why i'm trying on change client scripts. i'm tried below code, but my point is user wants to enter only 10 character not more than.
function onChange(control, oldValue, newValue, isLoading, isTemplate) {
if (isLoading || newValue === '') {
return;
}
// if(oldValue!=newValue)
var r=g_form.getValue('short_description');
var l=r.length;
if(l>10)
{
var t=r.slice(0,10);
g_form.setValue('short_description',t);
g_form.showFieldMsg('short_description','....................');
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-14-2019 11:49 PM
Hi JMR,
You can achieve the same via an onChange Client Script on change of that field. For example if you want to restrict the user from entering 10 character in the 'Short description' field, then you need to define the Client Script as below:
function onChange(control, oldValue, newValue, isLoading, isTemplate) {
if (isLoading || newValue === '') {
return;
}
//Check whether the field value is greater than 10 characters
if(newValue.length>10) {
g_form.clearValue('short_description'); //Clear the field value
alert('Please provide the field value of 10 Character at maximum'); //Show the alert message to the user
}
}
Hope this helps. Please mark the answer Correct/Helpful based on the impact.
Regards,
Amlan
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-16-2019 04:44 AM
Hi JMR,
Just following up with my last response. Did you able to validate the solution I have provided? Please let me know if you are still facing the issue?
Regards,
Amlan