s
Contact Login Register
h M

Dynamic Forms Demo 12


 Type anything in the textbox then hit the SEARCH button.  A message will be displayed stating There were no products that matched your entry.  However, if you enter the right product name , the form will submit as usual and you will be redirected to the "thank you" page. 

Enter this into the product field below:   AWC Logo Cap



Search           

Behind the Demo

 

This demonstrates how to validate a user's input using SQL Validation. This functionality allows you to execute a SQL statement to determine if the user's input is valid, and provide immediate feedback if it is not. 

In order to implement this functionality, we will do the following:

Create the Question

1) Create the question that will accept the user's input and set the following properties:

  • Give it the name "Product"
  • Give it the shortname "ProductName"
  • Set the "Question Type" to "Textbox"...Singleline textbox (Short)
  • If the field will be required, then set it's properties accordingly under the "Question Validation" settings.

 

Setup the SQL Validation

2) Under "Module Configuration" > "Validation Configuration" set the following properties:

  • Check the "Enable Server-side Validation" checkbox
  • Check the "Set focus on first validation error field checkbox
  • Check the "Enable custom SQL validation script" checkbox.
  • In the "Validation SQL Query" textbox enter the SQL statement or Stored Procedure name to execute to perform the validation.
    • Below is the SQL Stored Procedure created for this demonstration (this was created one time under Host, SQL):
      • CREATE PROCEDURE [dbo].[stp_SQLValidation]
        @ProductName nvarchar(100)
        AS
        SELECT COUNT(*) As IsValid
        FROM AdventureWorks.Production.Product
        WHERE Name = @ProductName
    • Below is the SQL that is called from within the 'Validation SQL Query' within this demonstration (this is whats entered into this form setting within the module configuration, validation, Validation SQL Query textbox):
      • stp_SQLValidation '$(ProductName)'
    • Note: In order to prevent a possible SQL Injection attack, it is recommended the SQL validation be performed using a stored procedure.
  • In the "Validation Error Message" textbox, enter the message to be displayed to the user in the event the SQL validation has failed.

In the above demonstration, if a user enters an invalid product name into the textbox a message will be displayed stating There were no products that matched your entry. If however, a valid product name is entered, such as "AWC Logo Cap", the form will submit as usual and you will be redirected to the "thank you" page.



See other Form Demos



Text/HTML


tip6.gifWould you like to set up your form just like this demo? 

     Simply download this template and save it using the exact file name (don't rename).  Next, upload it to File Manager and then go back to Dynamic Forms and click on Import Content.   

Get a copy now!



Let us do it for you



    Need help?  

Our super powers can make it happen. 

Let's start talking.




Enter your email below AND grab your spot in our big giveaway!

The winner will receive the entire Data Springs Collection 7.0 - Designed to get your website up and running like a DNN superhero (spandex not included).

  
Subscribe