WordPress.org

Ready to get started?Download WordPress

Forums

Quick Post Widget
[resolved] Form validation (7 posts)

  1. krama757
    Member
    Posted 3 years ago #

    Hi Inapan,

    Great job making this plugin. It's really versatile!

    Just had 3 "quick" questions for you and the community:
    - How would you validate the input in a custom field?
    Example: I have a custom field that asks the user for a date in mm-dd-yy format. If they enter hi-hi-hi, how would I take them back to the form submission page to make them correct this error?

    - How is the progress on showing only the visual editor going?
    The visual editor is so much more powerful than the regular form...it makes no sense for me to show just text boxes.

    - How would you resize the widget to only have a width of 1000 px instead of the default 100%?

    Thanks for the help.

  2. krama757
    Member
    Posted 3 years ago #

    Hmm, figured out my own hacks to do the form validation and the widget resize. I also just hid the text area for the post content and now people are forced to use the visual editor.

    Solving problems is fun :)

  3. inapan
    Member
    Plugin Author

    Posted 3 years ago #

    @krama757

    I'm sorry I haven't been able to dive into it yet. I have been very busy lately.

    Would you mind sharing your solutions on the forum so more of us can benefit from it.

    By the way, I agree with you: solving problems is fun (most of the time).

    inapan

  4. krama757
    Member
    Posted 3 years ago #

    Np Inapan...I'm just thankful that you made such an awesome plugin.

    I'll give a brief idea of what I did:
    Question: How would you resize the widget to only have a certain width?
    Solution:
    In quickpost-widget.php:
    Place: "<div class="quick_post">" before the line "<form autocomplete="off" method="post" name=quickpostwidget action="" >"
    Then place your "</div>" after the "</form>".
    Now in your template files, you can add custom style sheets for div.quick_post to choose your width, height, etc.

    Question: How would you validate the input in a custom field?
    Solution: Look for for ($cfn = 1; $cfn <= $qpw_custom_fields_count; $cfn++) {
    Here, if you know what your customfields are going to be then you can individually check your custom field values by using:

    if($_POST['customfield_1'] == 'Some incorrect input'){
    $error = 'yes';
    								?>
    								<script type="text/javascript">
    									document.getElementById(<?php echo '\'' . $customfield . '\''; ?>).style.border="solid 1px <?php echo $error_color; ?>";
    								</script> <?php
    							}

    This should allow you to control and check the inputs of your various custom fields assuming you know what each custom field is supposed to be.
    Question: How do you hide the textbox for post-content so that only the visual editor is used?
    Solution:
    In your widget settings, go to the style setting for post content and enter "visibility: hidden; position: absolute; top: 0; left: 0;" into the textbox.

    That should effectively hide your post-content text box so people are forced to use the visual editor.

    Happy Coding!

  5. krama757
    Member
    Posted 3 years ago #

    Question: How do you hide the textbox for post-content so that only the visual editor is used?

    This question should be bolded in the previous post >.< I wish the forum had a front-end edit function :P

  6. inapan
    Member
    Plugin Author

    Posted 3 years ago #

    Thanks for sharing!

    inapan

  7. Sorcol
    Member
    Posted 2 years ago #

    @krama757 Thanks for that...very useful tip for hiding the textbox.

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic