Set error label default as false globally - simple-form

I found a lot of articles describing that we can disable the error label by adding false to the form.
However, it seems that it is still very clumsy to set it one by one.
Therefore, I would like to ask if we can set a default false value in the initialisers to hide the error label, while we can set a true value when we want to use it?

Related

Set Data Validation Display style in Apps Script

Is it possible to set the dropdown display style in apps script?
After checking the documentation it looks like the API only allows you to choose between "Arrow" and "Plain Text".
The Apps Script documentation explains how to create data validation rules with a DataValidationBuilder. Most of the methods just set different DataValidationCriteria. Among those, the methods requireValueInList() and requireValueInRange() are the only ones that have a showDropdown parameter to set a dropdown, and the parameter's values can only be true or false. The default is true, which is equivalent to "Arrow" and false is equivalent to "Plain Text". As a boolean there's no third option for "Chip". Example:
// Set the data validation for cell A1 to require "Yes" or "No", with a dropdown menu.
var cell = SpreadsheetApp.getActive().getRange('A1');
var rule = SpreadsheetApp.newDataValidation().requireValueInList(['Yes', 'No'], true).build();
cell.setDataValidation(rule);
Looking at the Sheets REST API, which Apps Script is built on, the DataValidationRule works in a similar way, but this uses showCustomUi instead of showDropDown. Still, the limitation is the same to show only the basic arrow and plain text.
It just seems like a feature that hasn't been implemented yet. Maybe the "Chip" was added a while after the basic dropdown. You can try to request it in Google's issue tracker.

How can i force validation on the initial values in a formik form, when it mounts

I am in React 16+, using withFormik for the form.
Its a single field form which on initial use will have an empty string value. I want the initial value to be validated so the user knows they must fill a value.
So blank string "" initial value, i want the error to say "please enter a value" without the user touching or anything. onload.
formik docs claim it can do this thru the built in tools, but the library/docs dont add up.
validateOnMount:
https://formik.org/docs/api/withFormik#validateonmount-boolean
this value does nothing when set to true in my form. There are lots of logged issues of others having the same problems. It seems formik depreciated an old property that used to do this well. i cant find anything to do this without building some type of hack.
how can i have formik run the validation as ssoon as the from mounts.
in case your answer is to disable the "enableReinitialize" property, ive tried this in conjunction with validateOnMount: true and still get nothing.

Remove oscpu property from from window.navigator

If you are using FireFox, navigator has a property oscpu.
The property can be easily changed by appending general.oscpu.override value in about:config.
But, this option is present only in FireFox and does not exist in any other browser. This allows a 100% certainty to determine the type of browser.
Conventional means can not remove it. Whatever happened that ( oscpu in navigator) would return false.
All this does not work:
delete navigator.oscpu;
'oscpu' in navigator; // true
navigator.oscpu = null;
'serviceWorker' in navigator; // true
navigator.oscpu === null; // false
Object.defineProperty(navigator, "oscpu", {
configurable: true,
value: undefined
});
'oscpu' in navigator; // true
navigator.oscpu === undefined; // true
Are there ways to remove this property from navigator? And indeed any other parameter. I am writing a Firefox Add-on SDK extension.
There are potential side effects of doing what you are wanting to accomplish. It would be helpful to know what your goals are in order to determine a good way to accomplish what you desire.
However, for what you have specifically requested, removing navigator.oscpu in the current scope, the following works:
//This specific code relies on navigator referring to the object which you want to
// modify. In an Add-on SDK extension, if navigator is _actually_ the object you need
// to modify to accomplish what you desire will depend on the scope you are in and
// what object you have set the variable navigator to refer to.
delete navigator.__proto__.oscpu;
console.log(navigator.oscpu); // undefined
'oscpu' in navigator // false
Note that you will need to do this within every context/scope in which you desire for it to have effect. In general, this means that you will need to inject a content script into every page and frame in which you wish this to be the case. It also means that you should take care to only do it in the context/scopes in which you are wanting it to be seen by whatever JavaScript you are attempting to spoof (i.e. within the scope of page scripts, not in the scope of code running with Chrome privileges.).

AngularJS ng-value boolean validation

To be specific: I have two radio buttons and their ng-model value must be boolean. Since this is not possible with normal html value property I found useful Angularjs ng-value. Problem is when I want to do some validation, when radio button ng-value="false" is selected it recognizes it as an empty ng-model and we have validation error.
Example: http://plnkr.co/edit/lvdNHZoSSN1nM6uLyc0Q?p=preview
Any clue how to tackle this?
This is a bug.
value="true/false" won't work because your radio inputs won't be initialized and checked correctly when your model is loaded, but ng-value="true/false" won't work because "false" selections will cause the form to be invalid.
I was having the same problem and reported it as an issue, but since there's no telling when it will be resolved, I also came up with a workaround: ng-boolean-radio
It basically converts your model's boolean true / false values into string "true" / "false" values, which match your form's string value="true/false" attributes. This will allow the corresponding radio inputs to be checked by default when the model loads. It will also allow you to save "false" values because "false" != false.
Finally, it preserves the boolean datatype by converting the string "true" / "false" values back to boolean true / false before saving them in the model.
I hope that helps!
http://plnkr.co/edit/Y5vDuTug0kvS3Ut58Lz9?p=preview
Problem is in the required attribute.
I believe using ng-required="!user.gender" is what you're looking for.
Edit: it seems that ng-required, while slightly better, still doesn't work fully.
My recommendation is to omit require completely and initialize your model with a default value:
{gender: true} (false will work too).
I had this problem, too. Michael Moussa's directive was very good for debugging what the checkboxe's/radio button's actual modelValue is. As it turned out, a modelValue of false arrived undefined at the checkbox/radio button. Updating (from 1.2.0) to angular 1.2.5 fixed the problem for me.

mColorPicker error 'Invalid Property value' in IE7

I have recently downloaded mColorPicker.js from here
However, I am running into some issue with this -
When user enters an invalid color value like '#454545xxxx' in the color box, I get a js error - Invalid Property value in IE7 (working fine in Firefox)
error is coming in
jquery-1.4.2.min.js,
line 116 - if(e)f[b]=d
when d = "#454545xxxx"
Also, ColorPicker image is hidden for this textbox.
Any ideas?
The reason this is happening is that the plugin is trying to set the value of the background colour to exactly what the user typed, without doing any validation checking to make sure it is a valid colour. The plugin calls the jQuery .css() method to do this, which is why the error is occurring inside jquery-1.4.2.min.js.
If you are able to modify the plugin code, you can then add checks to make sure the value entered is a valid colour before proceeding.
You might also suggest adding this feature to the plugin author, or, if you get it working successfully, submitting your updated code to them so they can benefit from your work.
I had a quick look, but I don't have the time to properly make the necessary changes to the plugin to ensure it correctly validates the colour is valid in all the right places. Good luck!

Resources