JSFiddle - React, Tailwind, and code Playground
HTML
<script src="https://ajax.googleapis.com/ajax/libs/jqueryui/1.10.1/jquery-ui.js"></script>
<link rel="stylesheet" href="https://ajax.googleapis.com/ajax/libs/jqueryui/1.10.1/themes/ui-lightness/jquery-ui.css">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/x-editable/1.5.1/jqueryui-editable/css/jqueryui-editable.css">
<script src="https://cdnjs.cloudflare.com/ajax/libs/x-editable/1.5.1/jqueryui-editable/js/jqueryui-editable.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery-validate/1.13.1/jquery.validate.js"></script>
<p>name</p><a href="javascript:void(0)" id="name"></a>
<p>email</p><a href="javascript:void(0)" id="email"></a>
JavaScript
//Some separate script linked to HTML page
$(function () {
$.validator.editable = {};
$.validator.editable.form = $('<form />', {
css: {
position: 'absolute',
top: '-9999px'
}
}).append($('<input />', {
type: 'text'
})).appendTo('body');
$.validator.editable.initialize = function (validateObj) {
$.validator.editable.form.validate(validateObj);
}
$.validator.editable.validate = function (value, t) {
var input = $.validator.editable.form.find('input').attr('name', (name = t.getAttribute("name")) ? name : t.id).val(value);
if (!input.valid()) {
return input.next().html();
}
}
});
$(function () {
$.validator.editable.initialize({
rules: {
name: {
required: true,
maxlength: 4,
minlength: 2
},
email: {
required: true,
maxlength: 45,
email: true
}
}
});
$('#name').editable({
type: 'text',
title: 'name',
url: '/echo/json/',
pk: 123,
validate: function (value) {
return $.validator.editable.validate(value, this);
}
});
$('#email').editable({
type: 'text',
title: 'email',
url: '/echo/json/',
pk: 123,
validate: function (value) {
return $.validator.editable.validate(value, this);
}
});
});