The CreatorCon Call for Content is officially open! Get started here.

URL validation

Anna L
Tera Contributor

Hi, How would I validate a URL field on my request item form based on following criteria:

It should be entered by user in form of:

jb**.systemaudit.com

Basically it should stop user for submitting the request, so an onsubmit script,   Any script suggestions?

1 ACCEPTED SOLUTION

Here you, these are the 2 versions I have got for you


1) It takes any two characters(this include digits)


function onSubmit() {


  if(!(/jb.{2}.systemaudit.com/g.test(g_form.getValue("your field name goes here")))){


  alert("please enter in desired format");


  return false;


  }




2)It takes only 2 digits


function onSubmit() {


  if(!(/jb(\d){2}.systemaudit.com/g.test(g_form.getValue("your field name goes here")))){


  alert("please enter in desired format");


  return false;


  }


View solution in original post

6 REPLIES 6

The following will take jb followed by two digits only. It also escapes the dots which are special.



function onSubmit() {


  if(!(/jb[0-9][0-9]\.systemaudit\.com/g.test(g_form.getValue("your field name goes here")))){


  alert("please enter in desired format");


  return false;


  }



If you need to make adjustments to the regular expression pattern, there are lots of online references and tutorials to help de-mystify:


https://www.google.com/search?q=regular+expressions&oq=regular+expressions&aqs=chrome..69i57j0l5.263...


Here you, these are the 2 versions I have got for you


1) It takes any two characters(this include digits)


function onSubmit() {


  if(!(/jb.{2}.systemaudit.com/g.test(g_form.getValue("your field name goes here")))){


  alert("please enter in desired format");


  return false;


  }




2)It takes only 2 digits


function onSubmit() {


  if(!(/jb(\d){2}.systemaudit.com/g.test(g_form.getValue("your field name goes here")))){


  alert("please enter in desired format");


  return false;


  }