Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

All

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

<p>
  <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" />
  </label>
</p>
share|improve this question
add comment

1 Answer

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

or possibly:

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

Use the second one to avoid negative values.

share|improve this answer
    
thanks, its really works –  Webd106 Jun 23 '11 at 2:07
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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