Forum Discussion
MatthewBarrett
8 years agoQrew Member
I hate to change the subject, but I have a question back on the validate form fields with pattern and display message bubble subject. How do you correct from invalid to valid entry? I get the same result in my page as I do in the example page. Once the field is flagged as invalid it continues to report as invalid even after correction. Should I be using a change listener in the IOL page?
- _anomDiebolt_8 years agoQrew EliteThere is a bug in the code that I will look at. I did this very rapidly just to introduce a new idea.
- GauravSharma38 years agoQrew Commanderyes, I have noticed the same bug as Matthew noticed.
- _anomDiebolt_8 years agoQrew EliteI probably have a workaround that I will post after some testing. Luckily support for form validation has improved over time:
https://caniuse.com/#feat=form-validation
The tricky part is that the form validation was sort of designed to validate the entire form at the point in time just before it was submitted. What would be more appropriate for QuickBase users is to validate a field immediately after receiving input. My quick research found a workaround but I have other things to do at the moment so stay tuned. - MatthewBarrett8 years agoQrew MemberThank you! I'm tired of having invalid email addresses entered in the email address fields. I was thinking about using the keyup and replace method to eliminate unacceptable characters, but then I'd still need a formula field to check if the character string created something similar to an email address.
I'm attempting to create a pattern to cover both problems at once. Here's where I am now, which seems to catch it as a valid email address, but won't release after a fix when it was invalid first:
(function(){
var dbid = "mydbid";
var dbidTable1 = "mytbid";
var apptoken = "myapptoken";
$.ajaxSetup({data: {apptoken: apptoken}});
var querystring=document.location.search;
if(/a=er/i.test(querystring) || /a=nwr/i.test(querystring)) {
$("#_fid_6").attr({
pattern: "^((([!#$%&'*+\-/=?^_'{|}~\w])|([!#$%&'*+\-/=?^_'{|}~\w][!#$%&'*+\-/=?^_'{|}~\.\w]{0,}[!#$%&'*+\-/=?^_'{|}~\w]))[@]\w+([-.]\w+)*\.\w+([-.]\w+)*)$",
required: "required",
oninvalid: "setCustomValidity('Please use the format: xxxx@yyy.zzz')"
});
})
}
})();
My other thought was to use the keyup and replace with a target field that set as true or false whether the pattern matched. - _anomDiebolt_8 years agoQrew EliteI would not go crazy with the email regexp - it buys you nothing.
There are simpler ways to just check the validity of the entered email and provide feedback. My post was just introducing the HTML5 validation bubbles.
But I have other things to do and travel ahead of me so I will follow up later.