Hi All how to display popup message in catalog item hostname(one of the variable in catalog) contains less than 12 characters .popup message should display host name should contain atleast 12 characters

Himabindu
Giga Contributor

how to display popup message in catalog item hostname(one of the variable in catalog) if host name contains less than 12 characters  popup message should display host name should contain atleast 12 characters

@asifnoor 

2 REPLIES 2

Harish KM
Kilo Patron
Kilo Patron

Hi there are 2 ways to do this

1. You can write a onSubmit clientscript for example below. Refer attach screenshot

function onSubmit() {
    //get the value of host name

    var hostName = g_form.getValue('host_name');

    var length = hostName.length; //check the length
    alert(length);
    if (length <= 12) {
        alert("Host name should contain atleast 12 character");
        return false; //abort the submission

}

    }

}

2. Write onchange client script and display the error message below the variable

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


    //get the value of host name

    var hostName = g_form.getValue('host_name');

    var length = hostName.length;
    alert(length);
    if (length <= 12) {
       g_form.showErrorBox("host_name","Host name should have atleast 12 char");
    }

}
   

Regards
Harish

Hi Harish,

 

i tried this code it is accepting more than 12 characters .

my requirement it should accept exactly 12 characters  can you please help