We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy.
Unfortunately, activation email could not send to your email. Please try again.

add validation to check for valid telephone number

Thread ID:

Created:

Updated:

Platform:

Replies:

128126 Jan 4,2017 02:08 AM Jan 5,2017 06:37 AM ASP.NET MVC 1
loading
Tags: Grid
Edmund Herbert
Asked On January 4, 2017 02:08 AM

Hi Guys happy new year,
Could you tell me how to add validation in MVC 5 grid controll,
addrule to validate telephone number or cell number

Thanks

Edmund Herbert

Prasanna Kumar Viswanathan [Syncfusion]
Replied On January 5, 2017 06:37 AM

Hi Edmund, 

Thanks for contacting Syncfusion support. 

To add validation in grid control, use validationRules property of columns. If you have different field for both telephone and mobile number, use minlength and maxlength jQuery validation method. For example, in this sample we set validation for phone number using maxlength and minlength validation method.  

Find the code example and sample:  


@(Html.EJ().Grid<object>("FlatGrid") 
    .Datasource((IEnumerable<object>)ViewBag.datasource) 
    .AllowSorting() 
         ---------- 
     }) 
       .Columns(col => 
        { 
          --------------- 
            col.Field("Phone").HeaderText("Phone").ValidationRules(v => v.AddRule("required", true).AddRule("maxlength", 6).AddRule("minlength", 6)).TextAlign(TextAlign.Right).Width(75).Add(); 
        }) 
    ) 


Refer to the Help document for the validation.  


If you need to validate phone and mobile number in a single field, use custom validation. In addition to jQuery validation methods, you can also add your own custom validation methods for a specific column. Function call to custom validator function to be mentioned within ValidationRules property of Columns. 
 
For more information, please refer the below document and online sample.  
 
 

Regards, 
Prasanna Kumar N.S.V 


CONFIRMATION

This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.

;