restrict the semicolumn (;) in string filed

Gillerla Rajesh
Tera Contributor

when user fill (; )it will not allow replace (; )with (,) and update field how can i achive, provide me any source code for this.

4 REPLIES 4

Sohail Khilji
Kilo Patron

Hi @Gillerla Rajesh ,

 

Try the below :

 

 

var input = current.<nameofyourfield>.toString();
var output = input.replace(";", ",");
// add your update logic 
gs.print(output);



 

 


☑️ Please mark responses as HELPFUL or ACCEPT SOLUTION to assist future users in finding the right solution....

LinkedIn - Lets Connect

Amit Verma
Kilo Patron
Kilo Patron

Hi @Gillerla Rajesh 

 

Assuming you want to enforce these restrictions on a catalog field, you can make use of an On-Change Catalog Client Script on your field with below code :

 

function onChange(control, oldValue, newValue, isLoading) {
    if (isLoading || newValue == '') {
        return;
    }
    //Type appropriate comment here, and begin script below

    var inputString = g_form.getValue('description'); // change the field name as per your field
    var output = inputString.replace(";", ",");
    g_form.setValue('description', output); // Change the field name as per your field
}

 

Thanks & Regards

Amit Verma


Please mark this response as correct and helpful if it assisted you with your question.

Rohini S Sane
Tera Guru

Hi@Gillerla Rajesh ,

You can write on change client script.

function onChange(control, oldValue, newValue, isLoading, isTemplate) {
   if (isLoading || newValue === '') {
      return;
   }

  var str = g_form.getValue('field');
var rep = str.replace(";" , ",");
g_form.setValue(rep,'field');
   
}
Regards,
Rohini Sane

 

chetanb
Tera Guru

Hello @Gillerla Rajesh ,

 

you can try below code-

 

var input = current.getValue(current.sys_id);

var output = input.replace(";", ",");

current.setValue(current.sys_id,output);

if my answer has helped with your question, please mark my answer as accepted solution and give a thumb up.

 

Regards,

CB