EasyUI Forum

General Category => General Discussion => Topic started by: featheral on October 03, 2019, 06:12:26 AM



Title: form inputs: validation not working
Post by: featheral on October 03, 2019, 06:12:26 AM
Hi.
I'm attempting to introduce some new forms into an existing webapp.
input validation on existing forms works fine. But on new forms I've added, it doesn't work. I am finding it hard to spot the issue and would appreciate some guidance.

An example of an input would be:
Code:
<input name="name"  type="text"  class="easyui-validatebox" data-options="missingMessage:'foo',required:true" />
This validation isn't happening. Examining the DOM shows that the validatebox-text & validatebox-invalid classes, typically appended to invalid inputs, are not there.
If I call
Code:
$("form :input[name='name']").validatebox()
in the console, then the above classes appear, and the field is validated.

I cannot spot calls to validatebox() on the existing forms, so assume there's no need to call it explicitly. At a loss then as to why some form validation is occurring and some doesn't.
Thanks,


Title: Re: form inputs: validation not working
Post by: stworthy on October 04, 2019, 04:41:26 PM
Please look at this code.
Code:
<input name="name"  type="text"  class="easyui-validatebox" data-options="missingMessage:'foo',required:true" />

When you append this code to the form dynamically, you only create an <input> element with 'easyui-validatebox' class. You should create or parse it as an easyui component before using it.




Title: Re: form inputs: validation not working
Post by: featheral on October 07, 2019, 03:47:59 PM
Ok. When you say I need to
Quote
create or parse it as an easyui component before using it
could you elaborate on that? Better yet - point me to where the docs explain how parsing of input fields is invoked, and when it should be invoked. I cannot spot any 'parsing' triggered in the validatebox demo at https://www.jeasyui.com/demo/main/index.php?plugin=ValidateBox (https://www.jeasyui.com/demo/main/index.php?plugin=ValidateBox) - it only annotates divs with the 'easyui-validatebox' class and respective 'data-options'.

I am particularly keen to understand the use-case for the 'easyui-validatebox' class. If an input field has to be programmatically-set to validate, what is the use of declaring that class?

FWIW, the input in the form I am adding is not appended dynamically. It is sent as part of the DOM in the http response (I can see it in the response's payload).