Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

behavior: how to realize a required field's content must include the specified content

zhangqian04
Contributor
June 29, 2020

hi ,

When one field changes, another field is required to be required, and the content of this required field must contain some specified content.

At present, the required fields are required to be filled in, but the required contents are required to be filled in at the same time. I don't know how to do it.

example:  if A field changes, B must require, and B must contain 'like' 

behavior A filed:

if( A  changes)

{

B. setRequired(true)

Bcontent = B.getValue() as String

if(!Bcontent.contains("like")){     // question is :The B filled field content is not obtained,So it has always been setError

   B.setError("please input  right content!")

}

else

{

   B.clearError()

}

}

else

{

B. setRequired(false)

}

 

 

Best wishes !

1 answer

0 votes
Mathis Hellensberg
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
July 1, 2020

Hi @zhangqian04 

I'm not sure I completely understand, but this behaviour below makes a textfield required if any value in the selectfield is selected. I hope it can help you :)

Snipaste_2020-07-01_10-51-58.png

zhangqian04
Contributor
July 2, 2020

firstly thank you for reply,but this  doesn't solve my problem.

Mathis Hellensberg
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
July 2, 2020

How come? :)

zhangqian04
Contributor
July 5, 2020

At present, the required field  has been realized, but I don't know how to restrict it to fill in the specified contentbut at the same time. 

Suggest an answer

Log in or Sign up to answer