Search results

Validation

The TextBox supports three types of validation styles namely error, warning, and success. These states are enabled by adding corresponding classes .e-error, .e-warning, or .e-success to the input parent element.

tagHelper
validation.cs
@using Syncfusion.EJ2

@section ControlsSection{
<div class="control-section">
        <div class="control_wrapper accordion-control-section">
			<div class="e-input-group e-warning">
			 <input class="e-input" type="text" placeholder="Input with warning" />
		   </div>

		   <div class="e-input-group e-error">
			 <input class="e-input" type="text" placeholder="Input with error" />
		   </div>

		   <div class="e-input-group e-success">
			 <input class="e-input" type="text" placeholder="Input with success" />
		   </div>
        </div>
</div>
}

@section Script{
 <script>
        ej.base.enableRipple(true);

		// To get the all input fields and its container.

		var inputElement = document.querySelectorAll('.e-input-group .e-input,.e-float-input.e-input-group input');

		// Add 'e-input-focus' class to the input for achive ripple effect when focus on the input field.

		for (var i = 0; i < inputElement.length; i++) {
			inputElement[i].addEventListener("focus", function () {
				var parentElement = this.parentNode;
				if (parentElement.classList.contains('e-input-in-wrap')) {
					parentElement.parentNode.classList.add('e-input-focus');
				} else {
					this.parentNode.classList.add('e-input-focus');
				}
			});
			inputElement[i].addEventListener("blur", function () {
				var parentElement = this.parentNode;
				if (parentElement.classList.contains('e-input-in-wrap')) {
					parentElement.parentNode.classList.remove('e-input-focus');
				} else {
					this.parentNode.classList.remove('e-input-focus');
				}
			});
		}

		// Add 'e-input-btn-ripple' class to the icon element for achive ripple effect when click on the icon.

		var inputIcon = document.querySelectorAll('.e-input-group-icon');
		for (var i = 0; i < inputIcon.length; i++) {
			inputIcon[i].addEventListener('mousedown', function () {
				this.classList.add('e-input-btn-ripple');
			});
			inputIcon[i].addEventListener('mouseup', function () {
				var element = this;
				setTimeout(function () {
					element.classList.remove('e-input-btn-ripple');
				}, 500);
			});
		}

</script>
}
<style>
.e-input-group-icon:before {
  font-family: e-icons;
}

.e-input-group .e-input-group-icon.e-input-popup-date { /* csslint allow: adjoining-classes */
  font-size:16px;
}

.e-input-group.e-small .e-input-group-icon.e-input-popup-date { /* csslint allow: adjoining-classes */
  font-size:14px;
}

.e-input-group-icon.e-input-popup-date:before { /* csslint allow: adjoining-classes */
  content: "";
}

.e-input-group-icon.e-input-up:before { /* csslint allow: adjoining-classes */
  content: '\e85e';
}

.e-input-group-icon.e-input-down:before { /* csslint allow: adjoining-classes */
  content: "";
}

.e-input-group-icon.e-input-plus:before { /* csslint allow: adjoining-classes */
  content: '\e7ba';
}

.e-input-group-icon.e-input-minus:before { /* csslint allow: adjoining-classes */
  content: '\e814';
}

.e-input-group-icon.e-input-date:before { /* csslint allow: adjoining-classes */
  content: "";
}

.e-input-group-icon.e-input-left:before { /* csslint allow: adjoining-classes */
  content: '\e904';
}

.e-input-group-icon.e-input-right:before { /* csslint allow: adjoining-classes */
  content: '\e913';
}

.e-input-group-icon.e-input-reload:before { /* csslint allow: adjoining-classes */
  content: '\e837';
}

.e-input-group-icon.e-input-search:before { /* csslint allow: adjoining-classes */
  content: '\e806';
}

#input-container .e-input-group { /* csslint allow: adjoining-classes */
  margin: 30px 0;
}

#input-container .e-float-input { /* csslint allow: adjoining-classes */
  margin: 30px 0;
}
</style>
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Mvc;

namespace EJ2CoreSampleBrowser.Controllers
{
    public partial class TextboxController : Controller
    {
        // GET: //
        public IActionResult DefaultFunctionalities()
        {
            return View();
        }
    }
}

Output be like the below.

textbox