I want a validation rule, but I am no able to create the JavaScript myself.
I named the rule customval
The field must contain one of 5 numbers: BLDCT-0001 or BLDCT-0002 or BLDCT-0003 or BLDCT-0004 or BLDCT-0005
Otherwise an error message must show up.
I hope someone can create this JavaScript for me. I know where to put it.
I named the rule customval
The field must contain one of 5 numbers: BLDCT-0001 or BLDCT-0002 or BLDCT-0003 or BLDCT-0004 or BLDCT-0005
Otherwise an error message must show up.
I hope someone can create this JavaScript for me. I know where to put it.
Just use regex.
^BLDCT-000[1-5]$
^BLDCT-000[1-5]$
I have no idea what regex is nor how to use it.
I found a homepage which looks like some kind of tool: https://regexr.com/
Not sure if that is what you are talking about.
I have been testing with this script, but it is just working for a range of numbers 1-5
jQuery.fn.form.settings.rules.customval = function(value, param) {
var x = 5;
if (Number(value) > Number(x)) {
return false;
}else{
return true;
}
};
I found a homepage which looks like some kind of tool: https://regexr.com/
Not sure if that is what you are talking about.
I have been testing with this script, but it is just working for a range of numbers 1-5
jQuery.fn.form.settings.rules.customval = function(value, param) {
var x = 5;
if (Number(value) > Number(x)) {
return false;
}else{
return true;
}
};
There's a "regex" option in the validation tab of the field, put what I said in that. Or use javascript's "test()" function. Like
jQuery.fn.form blahblahblah = function(value, param) {But really, just use the regex option in the validation tab.
var patt = new RegExp("^BLDCT-000[1-5]$");
return patt.test(value);
}
Dont see the regex option in the validation tab of the field, so I used the script
But I dont get any error message if typing fx BLDCT-0009 which is actually not allowed

https://linedancetoender.dk/index.php/bordertraef-da/bordertraef-tilmelding-2020-da
jQuery.fn.form.settings.rules.customval = function(value, param) {
var patt = new RegExp("^BLDCT-000[1-5]$");
return patt.test(value);
}
But I dont get any error message if typing fx BLDCT-0009 which is actually not allowed
https://linedancetoender.dk/index.php/bordertraef-da/bordertraef-tilmelding-2020-da
oh wait a min. Maybe my own fault. Let me check that
Sorry it is working now.
I have 4 text fields in my form for those codes, and I only put the validation rule into the first field.
Now everything is working - thank you so much for your help
I have 4 text fields in my form for those codes, and I only put the validation rule into the first field.
Now everything is working - thank you so much for your help
This topic is locked and no more replies can be posted.