I added a Custom JQuery Validation method :-
$.validator.addMethod("ABN", function (value, element) {
return /[0-9]{12}/.test(value);
}, "Please enter a valid ABN.");
this.init =
.
.
$('#SuperFund_FundABN').rules("add", {
ABN: true
});
Which results in a 'nice' validation for my user.
Where as what has been autogenerated by the RAD tool :-
<input class="form-control" id="SuperFund_BSB" value="@Model.SuperFund.BSB" type="text" name="bsb" maxlength="@epayday.Epayday.SuperFunds.SuperFundConsts.MaxBSBLength" minlength="@epayday.Epayday.SuperFunds.SuperFundConsts.MinBSBLength" pattern="@epayday.Epayday.SuperFunds.SuperFundConsts.BSBRegex" />
Which provides an inconsistant user experience.
Am I missing something fundamental ? Or do I have to create custom JQuery Validation methods for regular expressions ?
7 Answer(s)
-
0
Hi @martin,
The regex when you entered on RAD tool and the one one on the client side is not the same I guess. You can compare the value of epayday.Epayday.SuperFunds.SuperFundConsts.BSBRegex (server side const) with the one you are using on the client side [0-9]{12}
The one on the server side is [0-9]{6} I guess. You need to make them same.
-
0
In my original question I was showing the two validation methods for two differnt different HTML inputs.
A better way to have asked this question would be :-
If I add
pattern="[0-9]{6-12}"
to a HTML input what extra do I need to get the JQuery Validator to validate that value ?Do I create my own custom JQuery Validation method (a per my original question) ? OR am I missing something obvious ?
Keep in mind the pages I am updating were generated by the RAD tool.
-
0
Hi @martin,
It seems like pattern attribute on the input doesn't work. Could you create an issue on https://github.com/aspnetzero/aspnet-zero-core/issues ?
-
0
I'm having trouble getting access to your git-hub and I will be away for 1 week so I'll have to raise that when I get back.
-
0
You can add your GitHub user on https://aspnetzero.com/LicenseManagement
-
0
Got back from my holidays and created an issue in GitHub as requested.
#<span></span>2218 martin-epayday
-
0