This is a migrated thread and some comments may be shown as answers.

Email field validation

1 Answer 2834 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Clinton Smyth
Top achievements
Rank 1
Clinton Smyth asked on 17 Oct 2012, 06:32 PM
Hi

I have a grid that contains a field for an email address.  I need to validate that the email address at least conforms to the basic "<name>@<domain>.<tld>" format when the user enters a record.

I tried setting the type to "email" in the dataSource model, as below:

$("#usersGrid").kendoGrid({
     dataSource: {
         schema: {
             model: {
                 id: "Id",
                 fields: {
                     Id: { editable: false },
                     Email: { type: "email", validation: { required: true} },
                     Username: { validation: { required: true} }
                 }
             }
         }
     },
...

Interestingly,  it worked for updates.  However, when I try to create a new record, it gives the error: "Uncaught ReferenceError: Email is not defined".

My questions are:

1. Is there a way to validate a field that contains an email address in the grid? 

2. Additionally, is there a way to detect a validation failure from outside the grid?  I'm implementing a wizard and want to prevent the user from proceeding if they press the 'Next' button when the grid has an outstanding validation failure.

1 Answer, 1 is accepted

Sort by
0
Accepted
Vladimir Iliev
Telerik team
answered on 22 Oct 2012, 10:12 AM
Hi Clinton,


Basically the KendoUI Model does not support such data type "email", however if you need to validate column of the Grid as an e-mail you should enable it in the column validation options:

$("#usersGrid").kendoGrid({
           dataSource: {
               schema: {
                   model: {
                       id: "Id",
                       fields: {
                           Id: { editable: false },
                           Email: { validation: { email: true, required: true} },
                           Username: { validation: { required: true} }
                       }
                   }
               }
           },


Kind Regards,
Vladimir Iliev
the Telerik team
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
Tags
Grid
Asked by
Clinton Smyth
Top achievements
Rank 1
Answers by
Vladimir Iliev
Telerik team
Share this question
or