I am developing a WordPress plugin. In this regard I am gathering data from User using a Form via Wordpress Admin Panel. My code is like below
<form method="post" name="newAddress" id="newAddress" class="validate" novalidate="novalidate">
<table class="form-table" role="presentation">
<tr class="form-field form-required">
<th scope="row">
<label for="name">
<?php _e( 'Name' ); ?>
</label>
</th>
<td>
<input name="name" type="text" id="name" value="<?php echo esc_attr( $new_user_login ); ?>" aria-required="true" autocapitalize="none" autocorrect="off" maxlength="60" />
</td>
</tr>
<tr class="form-field form-required">
<th scope="row">
<label for="email">
<?php _e( 'Email' ); ?>
</label>
</th>
<td>
<input name="email" type="email" id="email" value="<?php echo esc_attr( $new_user_email ); ?>" />
</td>
</tr>
<tr class="form-field">
<th scope="row">
<label for="phone_no">
<?php _e( 'Phone No' ); ?>
</label>
</th>
<td>
<input name="phone_no" type="text" id="phone_no" value="<?php echo esc_attr( $new_user_firstname ); ?>" />
</td>
</tr>
<tr class="form-field">
<th scope="row">
<label for="address">
<?php _e( 'Address' ); ?>
</label>
</th>
<td>
<input name="address" type="text" id="address" value="<?php echo esc_attr( $new_user_lastname ); ?>" />
</td>
</tr>
<tr class="form-field">
<th scope="row">
<label for="photo">
<?php _e( 'Photo' ); ?>
</label>
</th>
<td>
<input name="photo" type="text" id="photo" class="code" value="<?php echo esc_attr( $new_user_uri ); ?>" />
</td>
</tr>
</table>
<?php submit_button( __( 'Add New Address' ), 'primary', 'newAddress', true, array( 'id' => 'newAddress' ) ); ?>
</form>
My Form looks like below
How can I add Form validation here ?
I am developing a WordPress plugin. In this regard I am gathering data from User using a Form via Wordpress Admin Panel. My code is like below
<form method="post" name="newAddress" id="newAddress" class="validate" novalidate="novalidate">
<table class="form-table" role="presentation">
<tr class="form-field form-required">
<th scope="row">
<label for="name">
<?php _e( 'Name' ); ?>
</label>
</th>
<td>
<input name="name" type="text" id="name" value="<?php echo esc_attr( $new_user_login ); ?>" aria-required="true" autocapitalize="none" autocorrect="off" maxlength="60" />
</td>
</tr>
<tr class="form-field form-required">
<th scope="row">
<label for="email">
<?php _e( 'Email' ); ?>
</label>
</th>
<td>
<input name="email" type="email" id="email" value="<?php echo esc_attr( $new_user_email ); ?>" />
</td>
</tr>
<tr class="form-field">
<th scope="row">
<label for="phone_no">
<?php _e( 'Phone No' ); ?>
</label>
</th>
<td>
<input name="phone_no" type="text" id="phone_no" value="<?php echo esc_attr( $new_user_firstname ); ?>" />
</td>
</tr>
<tr class="form-field">
<th scope="row">
<label for="address">
<?php _e( 'Address' ); ?>
</label>
</th>
<td>
<input name="address" type="text" id="address" value="<?php echo esc_attr( $new_user_lastname ); ?>" />
</td>
</tr>
<tr class="form-field">
<th scope="row">
<label for="photo">
<?php _e( 'Photo' ); ?>
</label>
</th>
<td>
<input name="photo" type="text" id="photo" class="code" value="<?php echo esc_attr( $new_user_uri ); ?>" />
</td>
</tr>
</table>
<?php submit_button( __( 'Add New Address' ), 'primary', 'newAddress', true, array( 'id' => 'newAddress' ) ); ?>
</form>
My Form looks like below
How can I add Form validation here ?
Data Sanitization in Wordpress ... https://developer.wordpress/themes/theme-security/data-sanitization-escaping/
_e()
and__()
functions istextdomain
. Without textdomain your plugin will work but your plugin needs to follow the standard if you like to submit the plugin in WordPress repository. – Shah Alom Commented Nov 15, 2019 at 16:06