- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-07-2024 01:35 AM
Hi,
I have a requirement where the following format is only accepted for a field. Kindly help.
rocisw01nfs.unix.rabk.com:/appshares/san
Regards
Suman P.
Solved! Go to Solution.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-07-2024 02:46 AM
@Community Alums Please update your script as follows.
function onChange(control, oldValue, newValue, isLoading) {
if (isLoading || newValue == '') {
return;
}
var re = /^[a-z0-9]+.[a-z]+.[a-z]+.[a-z]+:\/[a-z]+\/[a-z]+$/;
if (!re.test(g_form.getValue('nfs_export')) {
g_form.addErrorMessage('Invalid format for NFS Export');
g_form.clearValue('nfs_export');
return false;
}
}
Hope this helps.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-07-2024 01:43 AM
@Community Alums Can you share some more examples or details what do you mean by format here? Some sample values might help.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-07-2024 01:49 AM
The field should only accept the following pattern.
rocisw01nfs.unix.rabk.com:/appshares/san
If I enter abc, this will not be accepted. If I enter abc/abc. This will not be accepted.
If I enter abc.abc.abc.abc/abc/abc then it will be accepted.
Regards
Suman P.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-07-2024 02:26 AM
@Community Alums Here is the script you should use to validate the field on the client side. Update it according to your need.
function onChange(control, oldValue, newValue, isLoading) {
if (isLoading || newValue == '') {
return;
}
//Type appropriate comment here, and begin script below
if (/^[a-z0-9]+.[a-z]+.[a-z]+.[a-z]+:\/[a-z]+\/[a-z]+$/.test(newValue)) {
alert('allowed');
} else {
alert('not allowed');
}
}

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-07-2024 02:33 AM
@Community Alums Could you please mark the answer correct if it managed to address your requirement.