jQuery Validator
Set the rules property of the jqxValidator.
Author: http://jqwidgets.com
HTML
<script src="https://jqwidgets.com/public/jqwidgets/jqx-all.js"></script>
<link rel="stylesheet" href="https://jqwidgets.com/public/jqwidgets/styles/jqx.base.css">
<link rel="stylesheet" href="https://jqwidgets.com/public/jqwidgets/styles/jqx.energyblue.css">
<form id="testForm" action="./">
<table class="register-table">
<tr>
<td>Username:</td>
<td>
<input type="text" id="userInput" class="text-input" />
</td>
</tr>
<tr>
<td>body:</td>
<td>
<textarea id="PlainTextBody"></textarea>
</td>
</tr>
</table>
</form>
<input type="button" style="margin:30px;" id="jqxbutton" value="Submit" />
JavaScript
$('#testForm').jqxValidator({
rules: [
{
input: '#userInput',
message: 'Username is required!',
action: 'keyup,blur',
rule: 'required'
}, {
input: '#PlainTextBody',
message: 'Html body is required!',
action: 'keyup,blur',
rule: function(input, commit) {
var editorValue = $.trim($(input.val()).text());
if (editorValue === "" || editorValue === '') {
return false;
} else {
return true;
}
}
},],
});
$("#jqxbutton").jqxButton({
theme: 'energyblue',
width: 100,
height: 30
});
$("#PlainTextBody").jqxEditor({
height: '240px',
width: '250px'
});
$("#jqxbutton").click(function () {
$('#testForm').jqxValidator('validate');
});