How to remove HTML tags from Description field using "Client Script".

Swaroop10
Giga Contributor

Hello,

I am trying to remove HTML Tags from Description field using Client Script. I can able to do with Business Rule, but as per my requirement i want to do it only with "Client Script".

Can anyone suggest me how to remove HTML Tags from Description field using Client Script.

 

 

Thanks in advance.

15 REPLIES 15

Hello Kunal,

I am using the below code in my Client Script, but its not working.

function onLoad() {
//Type appropriate comment here, and begin script below
var a = g_form.getValue('description');
var b = a.replace(/<\/?[^>]+(>|$)/g, "");
g_form.setValue(b);
}

 

Thanks & Regards,

S.Swaroop.

Ankur Bawiskar
Tera Patron
Tera Patron

Hi Swaroop,

Is description field a html field? if yes then why you want html tags to be removed;

if it is string field then why html tags are added to it as it doesn't make any sense adding those

Can you provide details on above

Regards
Ankur

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

Hello Ankur,

Thanks for the quick response.

Description field is "String" type and data coming to "Description" field is from another HTML field. While data getting updated from HTML field to "Description" field, it was coming with HTML tags. So, i want to remove those HTML tags using "Onload" client script.

 

 

Thanks & Regards,

S.Swaroop.