In the "JS Code" section of the "Load JavaScript" event, I have the following:
In the custom function, I use the respective function names, e.g. validateApiKeyId
No validation seems to occur at all - even if I also check a built-in validation option. The resulting class according to my web inspector is:
I assume this comes down to some error in my JS, but I don't see an error in the console. Any ideas?
function validateApiKeyId(el){
if ( !el.val().match(/\b\d{7}\b/) ) {
return false;
} else {
return true;
}
}
function validateApiKeyCode(el){
if ( !el.val().match(/\b([a-zA-Z]|\d){64}\b/) ) {
return false;
} else {
return true;
}
}
In the custom function, I use the respective function names, e.g. validateApiKeyId
No validation seems to occur at all - even if I also check a built-in validation option. The resulting class according to my web inspector is:
class="validate['custom:validateApiKeyId'] form-control"
I assume this comes down to some error in my JS, but I don't see an error in the console. Any ideas?
Sorry, meant to say "In the custom function [field in the Validation section for the text box], I use the respective function names, e.g. validateApiKeyId"
As an update, I tried removing the value for the function and added this to class:
That didn't work either.
validate['length[7,-1]']
That didn't work either.
Hi CMG,
Sorry for the late reply!
I have just tested this code in a "Load JS" action and uses "test" in the "custom" box under the validation tab of a "text" field:
The validation has always failed, but when changing "false" to true the form could be posted, so you need to double check the rules in your code and make sure that they work as expected, try the following site for live regex testing:
http://www.regexr.com/
Regards,
Max
Sorry for the late reply!
I have just tested this code in a "Load JS" action and uses "test" in the "custom" box under the validation tab of a "text" field:
function test(el){
return false;
}
The validation has always failed, but when changing "false" to true the form could be posted, so you need to double check the rules in your code and make sure that they work as expected, try the following site for live regex testing:
http://www.regexr.com/
Regards,
Max
No worries, thanks for taking a look.
The regex matches as I expect.
The first rule ensures only 7 digits are provided, the second rule ensures that only 64 alphanumeric characters are entered.
The regex matches as I expect.
The first rule ensures only 7 digits are provided, the second rule ensures that only 64 alphanumeric characters are entered.
Huh, changed the name to "checkAPIKeyId" and "checkAPIKeyCode" and it worked... weird! I didn't change anything else, so I don't know... well, solved I guess?
Maybe there was a caching issue, because this change should not have any effect on the function call! :?
This topic is locked and no more replies can be posted.