EasyUI Forum
April 29, 2024, 09:24:56 AM *
Welcome, Guest. Please login or register.

Login with username, password and session length
News:
 
   Home   Help Search Login Register  
Pages: [1]
  Print  
Author Topic: form inputs: validation not working  (Read 5535 times)
featheral
Newbie
*
Posts: 14


View Profile
« 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,
Logged
stworthy
Administrator
Hero Member
*****
Posts: 3581


View Profile Email
« Reply #1 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.


Logged
featheral
Newbie
*
Posts: 14


View Profile
« Reply #2 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 - 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).
« Last Edit: October 07, 2019, 08:10:18 PM by featheral » Logged
Pages: [1]
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.18 | SMF © 2013, Simple Machines Valid XHTML 1.0! Valid CSS!