Service Catalog accepts only alphanumeric values

mano9335
Kilo Contributor

I need a client script that accepts alphanumeric, excluding special characters and 'na' 'n/a' 'None'. I have single line text box to that field. Please anyone help me with this.

Thanks

17 REPLIES 17

Hi Chirag



This code works only for one field. Is there any way that we can have this work for 6 fields.



I believe this can be done through macro but not sure where to find the code.



Please advise



Thanks


Search in community if you can find the code which you are looking for.



and   incase if you are planning to use this catalog item in service portal, in that case UI macros are not supported in service portal, so my suggestion is to declare function with onLoad client script and call that function in onChange client script of all 6 fields.


Thank you Chirag, That was helpful. Since we are planning to move to service portal soon I should follow your suggestion



thanks


Hi Chirag,



I wrote the following code on OnSubmit but the problem is even though the result is false it is still submitting



function onSubmit() {


    //Type appropriate comment here, and begin script below


    var alpha = new RegExp("^[a-zA-Z0-9]*$");


  var projectKey=g_form.getValue('project_key');


  alert("value"+projectKey);


  var res=alpha.test(projectKey);


  if (!res) {


            g_form.showFieldMsg('project_key', 'Invalid input', 'error');


  }


}


you need to add "return false;" or "return;" after field error message.