Allow only * and number in a string field

Anantharam
Tera Contributor

Dear Team,

 

Good day!!!

I want to allow astrick (*) and the number in a string field. I know for excluding all the special characters. In that, how to exclude only * is confusing. pls help

 

Thanks

 

It worked for me...

 

var pattern =/^[0-9'"_*]*$/;

var name = g_form.getValue('formula_number');
if (!pattern.test(name)){


alert("Only Numbers and * are allowed in this field");
g_form.setValue('formula_number','');

}

1 REPLY 1

Tony Chatfield1
Kilo Patron

Hi, unfortunately your question\requirement is not clear as to the format of your data.
Is this to match any number of decimal characters and any number of *, in any order?
Or are you trying to match an exact pattern?

Perhaps you could provide examples?