javascript - Limit number of characters in input field with PHP -
i'm creating database of people using this wordpress plugin. on signup form, want limit number of characters users can input in fields, don't know how, i'm not programmer , have limited knowledge of php , javascript. can't edit html directly since i'm using plugin, can't use maxlength html attribute. signup page based on following php template plugin, guess that's need edit, how?
<?php /* * bootstrap template signup form * * outputs twitter bootstrap-compatible form * http://twitter.github.com/bootstrap/index.html * */ ?> <div class="wrap <?php echo $this->wrap_class ?>" > <?php // how html wrapper error messages can customized $this->print_errors( '<div class="alert %1$s">%2$s</div>','<p>%s</p>' ); ?> <?php $this->print_form_head(); // must included before fields output ?> <div class="form-horizontal pdb-signup"> <?php while ( $this->have_groups() ) : $this->the_group(); ?> <fieldset class="field-group field-group-<?php echo $this->group->name ?>"> <?php $this->group->print_title( '<legend>', '</legend>' ) ?> <?php $this->group->print_description() ?> <?php while ( $this->have_fields() ) : $this->the_field(); ?> <?php $feedback_class = $this->field->has_error() ? 'error' : ''; ?> <div class="<?php $this->field->print_element_class() ?> control-group <?php echo $feedback_class ?>"> <label class="control-label" for="<?php $this->field->print_element_id() ?>" ><?php $this->field->print_label(); // function adds required marker ?></label> <div class="controls"><?php $this->field->print_element_with_id(); ?> <?php if ( $this->field->has_help_text() ) :?> <span class="help-block"> <?php $this->field->print_help_text() ?> </span> <?php endif ?> </div> </div> <?php endwhile; // fields ?> </fieldset> <?php endwhile; // groups ?> <fieldset class="field-group field-group-submit"> <div id="submit-button" class="controls"> <?php $this->print_submit_button('btn btn-primary'); // can specify class button ?> <span class="pdb-retrieve-link"><?php $this->print_retrieve_link(__('forget private link? click here have emailed you.','participants-database')); ?></span> </div> </fieldset> </div> <?php $this->print_form_close() ?> </div>
find out id of input field , add following script file.
<script type="text/javascript"> window.onload = function() { jquery('#input_field_id').attr('maxlength','100'); } </script>
Comments
Post a Comment