<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>question Re: Restirct a catalog field to allow alphanumeric values and not special characters in ITSM forum</title>
    <link>https://www.servicenow.com/community/itsm-forum/restirct-a-catalog-field-to-allow-alphanumeric-values-and-not/m-p/2691838#M504473</link>
    <description>&lt;P&gt;Hi &lt;a href="https://www.servicenow.com/community/user/viewprofilepage/user-id/257985"&gt;@KS13&lt;/a&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Below is the script.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;    var field_value = g_form.getValue('your_catalog_field'); // Replace 'your_catalog_field' with the actual field name.
    var regex = /^[a-zA-Z0-9.-]+$/; // Regular expression to allow alphanumeric, dashes, and dots.

    if (!regex.test(field_value)) {
        alert("Invalid input! Please use only alphanumeric characters, dashes, and dots.");
      
    }

   &lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;You can also do this with Validation regex option for this.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="VishalBirajdar_0-1696471900408.png" style="width: 400px;"&gt;&lt;img src="https://www.servicenow.com/community/image/serverpage/image-id/294424iA1B68E7F5B910EAC/image-size/medium?v=v2&amp;amp;px=400" role="button" title="VishalBirajdar_0-1696471900408.png" alt="VishalBirajdar_0-1696471900408.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Thu, 05 Oct 2023 02:11:51 GMT</pubDate>
    <dc:creator>Vishal Birajdar</dc:creator>
    <dc:date>2023-10-05T02:11:51Z</dc:date>
    <item>
      <title>Restirct a catalog field to allow alphanumeric values and not special characters</title>
      <link>https://www.servicenow.com/community/itsm-forum/restirct-a-catalog-field-to-allow-alphanumeric-values-and-not/m-p/2691748#M504470</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;/P&gt;&lt;P&gt;Hoping someone can guide me to write a simple onChange catalog client script.&amp;nbsp;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Have a requirement, where a catalog field should allow alpha-numerical values and not allow special characters EXCEPT 'dashes' and 'dots/periods'&lt;/P&gt;&lt;P&gt;For example:&lt;/P&gt;&lt;P&gt;Allow: Test-123.com OR Test.123-456.&lt;/P&gt;&lt;P&gt;Restrict: Test-123$%^&amp;amp;.com&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;If allowed, set value, if Restricted, then throw an error message.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you in advance&lt;/P&gt;&lt;P&gt;KS&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 04 Oct 2023 21:09:58 GMT</pubDate>
      <guid>https://www.servicenow.com/community/itsm-forum/restirct-a-catalog-field-to-allow-alphanumeric-values-and-not/m-p/2691748#M504470</guid>
      <dc:creator>KS13</dc:creator>
      <dc:date>2023-10-04T21:09:58Z</dc:date>
    </item>
    <item>
      <title>Re: Restirct a catalog field to allow alphanumeric values and not special characters</title>
      <link>https://www.servicenow.com/community/itsm-forum/restirct-a-catalog-field-to-allow-alphanumeric-values-and-not/m-p/2691838#M504473</link>
      <description>&lt;P&gt;Hi &lt;a href="https://www.servicenow.com/community/user/viewprofilepage/user-id/257985"&gt;@KS13&lt;/a&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Below is the script.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;    var field_value = g_form.getValue('your_catalog_field'); // Replace 'your_catalog_field' with the actual field name.
    var regex = /^[a-zA-Z0-9.-]+$/; // Regular expression to allow alphanumeric, dashes, and dots.

    if (!regex.test(field_value)) {
        alert("Invalid input! Please use only alphanumeric characters, dashes, and dots.");
      
    }

   &lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;You can also do this with Validation regex option for this.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="VishalBirajdar_0-1696471900408.png" style="width: 400px;"&gt;&lt;img src="https://www.servicenow.com/community/image/serverpage/image-id/294424iA1B68E7F5B910EAC/image-size/medium?v=v2&amp;amp;px=400" role="button" title="VishalBirajdar_0-1696471900408.png" alt="VishalBirajdar_0-1696471900408.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 05 Oct 2023 02:11:51 GMT</pubDate>
      <guid>https://www.servicenow.com/community/itsm-forum/restirct-a-catalog-field-to-allow-alphanumeric-values-and-not/m-p/2691838#M504473</guid>
      <dc:creator>Vishal Birajdar</dc:creator>
      <dc:date>2023-10-05T02:11:51Z</dc:date>
    </item>
    <item>
      <title>Re: Restirct a catalog field to allow alphanumeric values and not special characters</title>
      <link>https://www.servicenow.com/community/itsm-forum/restirct-a-catalog-field-to-allow-alphanumeric-values-and-not/m-p/2691901#M504476</link>
      <description>&lt;P&gt;HI&amp;nbsp;&lt;a href="https://www.servicenow.com/community/user/viewprofilepage/user-id/257985"&gt;@KS13&lt;/a&gt;&amp;nbsp;,&lt;BR /&gt;I trust you are doing great.&lt;BR /&gt;&lt;SPAN&gt;Here's a simple &lt;/SPAN&gt;onChange&lt;SPAN&gt; catalog client script for your requirement:&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;function onChange(control, oldValue, newValue, isLoading) {
    if (isLoading || newValue === '') {
        return;
    }

    // Regular expression to allow alphanumeric, dashes, and dots/periods
    var regex = /^[A-Za-z0-9-.]+$/;

    if (!regex.test(newValue)) {
        // If the value does not match the regex, show an error message
        g_form.showFieldMsg(control, 'Special characters are not allowed except dashes and dots/periods.', 'error');
        g_form.clearValue(control); // Optionally, you can clear the field value
    } else {
        // If the value matches the regex, clear any previous error messages
        g_form.hideFieldMsg(control);
    }
}&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 05 Oct 2023 03:54:15 GMT</pubDate>
      <guid>https://www.servicenow.com/community/itsm-forum/restirct-a-catalog-field-to-allow-alphanumeric-values-and-not/m-p/2691901#M504476</guid>
      <dc:creator>Amit Gujarathi</dc:creator>
      <dc:date>2023-10-05T03:54:15Z</dc:date>
    </item>
    <item>
      <title>Re: Restirct a catalog field to allow alphanumeric values and not special characters</title>
      <link>https://www.servicenow.com/community/itsm-forum/restirct-a-catalog-field-to-allow-alphanumeric-values-and-not/m-p/2692805#M504545</link>
      <description>&lt;P&gt;Hi Amit,&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you for the guidance. It works partially. It won't throw the error.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 05 Oct 2023 15:26:39 GMT</pubDate>
      <guid>https://www.servicenow.com/community/itsm-forum/restirct-a-catalog-field-to-allow-alphanumeric-values-and-not/m-p/2692805#M504545</guid>
      <dc:creator>KS13</dc:creator>
      <dc:date>2023-10-05T15:26:39Z</dc:date>
    </item>
  </channel>
</rss>

