Interested in a ServiceNow event built for developers? Registration for now[dev]26 is officially open!

Text box should start with '_'

mohammedhyderal
Kilo Contributor

Hi All,

I have a requirement of placing a validation   in the text box,

It should start with '_A' , If not it should throw as error

16 REPLIES 16

Ya thanks i did it


mohammedhyderal
Kilo Contributor

Hi All,



I did find a easy way to do it as well,



To check whether the textbox starts with some requested characteron SR



function onChange(control, oldValue, newValue, isLoading) {


    if (isLoading || newValue == '') {


          return;


    }


      if (newValue.indexOf('-A') != 0){


  alert('Please prefix with -A');


  g_form.setValue('check','');


  }




   


}



Please mark it if found helpful


Hi Mohammed,



Is your query solved? if yes pls mark the reply as Correct so that the thread is closed.



Thanks


Ankur


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

Hi Mohammed,



Can you mark the answer as correct? This helps in closing out the thread



Thanks


Ankur


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

He will when he will.   Posting 3 times specifically requesting an answer to get marked is a bit much.