Remote validation

Greetings,


I would like to know if it's possible to use remote validation with the rich text box component.

More info about remote validation( Model validation in ASP.NET Core MVC | Microsoft Docs)

Atm my RTE is rendered like this:


           <ejs-richtexteditor id="RedenOmschrijving" value="@Model.RedenOmschrijving">

              <e-richtexteditor-pastecleanupsettings Prompt="false" deniedTags="@ViewBag.deniedTags" keepFormat="false"></e-richtexteditor-pastecleanupsettings>

              <e-richtexteditor-toolbarsettings items="@ViewBag.tools"></e-richtexteditor-toolbarsettings>

              <e-content-template>

              </e-content-template>

            </ejs-richtexteditor>


I think i need to use asp-for for being able to use the remote validation, but that doesn't work. 

I need remote validation since i need 2 properties to be checked.

Can you guys help me?


2 Replies

VJ Vinitha Jeyakumar Syncfusion Team September 3, 2021 03:13 PM UTC

Hi Jordi, 
 
 
Currently, we are validating your reported query. We will update you the further details in two business days on 7th September. 
 
Regards, 
Vinitha. 



VJ Vinitha Jeyakumar Syncfusion Team September 7, 2021 03:43 PM UTC

Hi Jordi, 
 
 
Greetings from Syncfusion support 
 
 
We have validated your query “I would like to know if it's possible to use remote validation with the rich text box component 
 
Your requirement to use remote validation with the Rich Text Editor component can be done by using “ejs-for” property. We have also prepared a sample for your reference, 
 
Code snippet: 
Index.csHtml 
<form asp-controller="Home" asp-action="Index" method="post"> 
 
    <ejs-richtexteditor id="Rte1" ejs-for="Rte"> 
         
    </ejs-richtexteditor> 
    <span asp-validation-for="Rte" class="text-danger"></span> 
 
    <br /> 
    <button type="submit">Save</button> 
</form> 
 
<script>$.validator.setDefaults({ignore: [],});</script> 
 
EmployeeInputModel.cs 
namespace WebApplication2.Models 
{ 
    public class EmployeeInputModel 
    { 
        [Required] 
        [Remote(action: nameof(HomeController.ValidateRte), 
            controller: "Home", 
            ErrorMessage = "The RTE value can't be active", 
            HttpMethod = nameof(HttpMethod.Get))] 
 
        public string Rte { get; set; } 
    } 
} 
HomeController.cs 
public class HomeController : Controller 
    { 
 
        public IActionResult Index() 
        { 
             
             
            return View(new EmployeeInputModel()); 
        } 
 
        [HttpPost] 
        [ValidateAntiForgeryToken] 
        public IActionResult Index(EmployeeInputModel model) 
        { 
            if (!ModelState.IsValid) 
            { 
                return View(model); 
            } 
 
            var json = JsonConvert.SerializeObject(model); 
            return Content(json); 
        } 
 
         
        public JsonResult ValidateRte(string rte) 
        { 
            if (rte.ToLower() == "<p>active</p>") 
                return Json(data: false); 
 
            return Json(data: true); 
        } 
 
 
 
 
Please check the above code snippet, sample and demos, and let us know if it satisfies your requirement. 
 
Regards, 
Vinitha. 


Loader.
Up arrow icon