Now i am using WordPress, here right now i have a problem How can i valid my text filed input only inter value. Here is my code

  <label for="<?php echo $this->get_field_id('num_post'); ?>">
    <?php _e( 'Number of posts to show:' ); ?>
    <input id="<?php echo $this->get_field_id( 'num_post' ); ?>" name="<?php echo $this->get_field_name( 'num_post' ); ?>" type="text" value="<?php echo   $instance['num_post']; ?>" size="3" />
<?php print (int) $instance['num_post']; ?>

or possibly:

<?php print absint( $instance['num_post'] ); ?>

Use the second one to avoid negative values.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.