Create the Block:

Inside the Block directory, create a Directory Add and PHP file named Add.php.

 

View this link for form validation method and this

 

Include form action from block 

return $this->getUrl('training/post/addpost');

 

Add form key for security

 <?php echo $block->getBlockHtml('formkey'); ?>

 

Add valition 

data-mage-init='{"validation": {}}'