How to validate a SmartForm Textbox for required input

  • 27 January 2015
  • 5 replies
  • 14 views

Badge +3

I'm a newbie and struggling with something that is probably easy if you know what your doing.  I've searched for this question in this forum and Google and not finding the answer in a way that I can understand what I need to do.

 

My question is how do I validate that a required field has input in a SmartForm Textbox?

 

It appears that I need to set up a validation pattern to check for required input and then set up a rule for The Form Passes Validation.  I'm just unsure how to set up the validation pattern to check for required input.

 

When I click on the textbox, there is the section for Validation that has 3 options:  Max Length, Pattern, and Message.  I assume I click on the Patten to add a pattern for required input.  But I'm not understanding how to do that.  Can someone point me in the right direction?  With a pretty specific example.

 

Thanks for your help.


5 replies

Badge +8

Hello,

 

By saying "required input" I am assuming you mean that the field cannot be null. If that is what you mean you can create a rule stating that the control must contain a value. Do you have a button of somesort that is used to transfer data? An example would be adding rules to the button control stating that if the text box control has a value than submit the form, if not than show a message to the user which you could customize dipicting the fact that the text box needs to have a value.

 

 

Does this help?

 

Thanks!

 

Matt

Badge +3

Sorry, I could have asked the question better.  I'm using creating this SmartForm to perform CRUD (Create,Read,Update,Delete) functions on a SQL table.  There is a ListView of the existing data in the table. 

 

I'm using the Toolbar Button for Add to add new rows to the table.  When I click on the Toolbar Add button, textbox fields are displayed at the bottom of the ListView.  I'm unsure how to validate that the textboxes have input.  Because you are right, I don't want them to be null.

 

I was trying to use an editable Listview.  But I think I would be better off having a non-editable ListView.  And having a ItemView for Adding and Changing rows.  That ItemView would have a separate button to save data to the database.  So I could have a validation rule when that button is clicked to verify that all of the fields have input.  But I'm still unsure of exactly how to do that.

 

Sorry for being such a K2 newbie.  This is probably really easy to do once you know what your doing.

 

Thanks for your help.

Badge +8

Hello,

 

Yes that makes sense. You can add the rules to your button that will load the data input from the textbox control to the database. I have attached a screen shot below so you can see the logic i used to perform that function. This rule was added to the button control on my form. I am also pasting a URL with some logic regarding how rules are used in smartforms. Please let me know if you have any other questions! Thanks!

 

http://help.k2.com/onlinehelp/k2smartforms/userguide/1.0.4/webframe.html#SF_-_Rule_Designer_-_Rules_Wizard.html

 

Regards,

 

Matt


16201i0174C82049DE9CD2.png
Badge +3

Thanks.  Your answer makes sense.  I was trying to make it harder than it was.  I really appreciate the screen-shot.

Badge +8

Excellent! I'm glad it worked. Enjoy your day!

 

Regards,

 

Matt

Reply