User Input and Validation Message

Hi,

how to show validation message in User Input using onCustomValidation( )?
This code does not show the message:

$w(“#phoneNumberInput”).onCustomValidation( (value, reject) => {
reject(“Check phone number”);
});

You can find that out from the tutorials here through Validation Message.
https://support.wix.com/en/article/corvid-about-validating-user-input-with-code
https://www.wix.com/corvid/example/custom-validations

validationMessage

Gets a message indicating why the element is invalid, or an empty string if the message is valid.

Description

Set the value of the validationMessage property using the reject() function of the onCustomValidation() event handler.

For all the reference about the API, then see here.
https://www.wix.com/corvid/reference/$w.ValidatableMixin.html

Yes, thanks. But it does not work completely without Wix Forms. User Input is in invalid state, but message does not appear.

Wix Forms? Where do you get Wix Forms from?

The above links are for creating your own user input forms yourself with the use of Wix Code too.

The example link is one that you can open up in Wix Editor and see the whole user input form already laid out in the Editor, along with all the code already listed in the page tab too.

No where is Wix Forms stated.

Like this tutorial here, no Wix Forms is used!
https://support.wix.com/en/article/creating-a-form-with-user-input-elements

Or simply add a Wix Submit button that gives you the option of adding passed and failed validation messages in it’s own settings automatically.
https://support.wix.com/en/article/adding-a-submit-button-to-your-form

Wix Forms is from Add Apps menu… Is it possible to call onCustomValidation from button.onClick to get something like this, but without connecting button to the wix database:

I know perfectly well how to get to Wix Forms! I was responding to your comment on it of ‘But it does not work completely without Wix Forms.’

As for showing the message…

validationMessage

The validationMessage property returns a message indicating why an invalid element is invalid. You can set the validationMessage using the reject() function. If you don’t set a custom message, the validationMessage may contain a standard validation message, such as “value missing” or “type mismatch”.

It is already shown perfectly clear in the code in the example I had already linked to earlier in a previous post.

You can find that out from the tutorials here through Validation Message.
https://support.wix.com/en/article/corvid-about-validating-user-input-with-code
https://www.wix.com/corvid/example/custom-validations

validationMessage

Gets a message indicating why the element is invalid, or an empty string if the message is valid.

Description

Set the value of the validationMessage property using the reject() function of the onCustomValidation() event handler.

For all the reference about the API, then see here.
https://www.wix.com/corvid/reference/$w.ValidatableMixin.html

Thanks for reply! You were asking where I got Wix Form from… I just let you know where…

In my first post there is code for event handler and there is call of reject with message. This message never appears after onCustomValidation processed. So I would like to know how to show it without submit button connected to wix database.

Is there anyone from Wix Corvid team who can answer this question?

Wix Form is not integrated with Corvid.

Hi Yisrael, my question is not about Wix Form, it is about how to show validation message with reject and without connection submit button to wix database.

But you stated:

  • “But it does not work completely without Wix Forms.”

  • "Wix Forms is from Add Apps menu… Is it possible to call onCustomValidation from button.onClick to get something like this, but without connecting button to the wix database: "

The validation stuff doesn’t work with Wix Forms (from the Add Apps menu). You need to create your own form. See the Forms examples .

The links whisky man gave you explain how to to do custom validations. The Custom Validations example is excellent.

Yisrael,

my statement: Validation message does not work(appear) completely without Wix Forms or with my own form which does not contain submit button connected to database.

All these useful links DO NOT answer my question: how to show validation message with my own form which does not contain submit button connected to wix database.
Am I wrong?

PS. Can you explain your statement: Wix Form is not integrated with Corvid.
Because it is possible to use onCustomValidation with Wix Forms Input Fields.

Please post the editor URL of your site. Only authorized Wix personnel can get access to your site in the editor. Please include the name of the page involved.

You can use a before save datahook as stated in the tutorial.
https://www.wix.com/corvid/example/custom-validations

When the user clicks the Done button, before saving the data in the reservations collection, we use a dataset onBeforeSave event handler to check if all the field values are valid. If they are not, we display relevant error messages in a text element which expands at the bottom of the form.

Yisrael,

could I just provide you with test case description instead of sharing sharing editor links?

  1. Create new page
  2. Add User Input with name testInput and Button (do not connect Submit Button to database!)
  3. Edit Page Code and add:
    $w.onReady( function () {
    $w(“testInput”).onCustomValidation( (value, reject) => {reject(“Input is not good”); });

});
4. Press Preview page
5. Click the input field and exit it, no message will be displayed

Question: how to show Validation message?

givemeawhisky, thanks you very much for your help and links. But there is no database in this issue, so there is no onBeforeSave event handler… thanks again, there are enough links for me just now.

You should open the Validate a form example in your editor and see how it works.

Yisrael,

I have finished with this example… Submit button is connected to database in this example and YES it will work.

But my question…

Is there any person from Wix who can answer without all these links?
Just direct answer not links…

Direct answer: I opened the example, disconnected the Submit button - and it worked.

Thanks a lot! I will try to disconnect!