You are mixing PHP
and Javascript
.
The part between <script>
must not be in the PHP
code, but you could put it in the variable just after </form>
.
Another way of doing it would be to create a Javascript
file myfunctions.js
, putting the code into it and enqueueing it.
The code would be:
add_action( 'wp_enqueue_script', 'load_jquery2' );
function load_jquery2() {
wp_enqueue_script( 'jquery' );
}
function add_my_css_and_my_js_files(){
wp_enqueue_script('jquery-validate-min', plugins_url('activate/jquery_validate_min.js', __FILE__ ) );
}
add_action('wp_enqueue_scripts', "add_my_css_and_my_js_files");
function mp_calcs_display() {
return '
<form name="calsinput" action="" method="post" id="calsinput" >
<h1> Process </h1>
<p> operation type always robot </p>
<br> <br>
Number of welds: <input type="number" name="numberofwelds" class="required digits" title="This field is required and must be a no." >
<br> <br>
Number of construction welds: <input type="number" name="numberofconwelds" class="required digits" title="This field is required and must be a no.">
<input type="submit" value="Calculate cycle time ">
</form>
<script type="text/javascript">
jQuery(document).ready(function($) {
$("#calsinput").validate();
});
</script>';
}