javascript - html <input needs to contain specific text -


i have input field , button. want accept text contains words choose.

    <input type="hidden" name="post_id" id="fep-post-id" value="<?php echo $post_id ?>">      <button type="button" id="fep-submit-post" class="active-btn">go</button><img class="fep-loading-img" src="<?php echo plugins_url( 'static/img/ajax-loading.gif', dirname(__file__) ); ?>"/> 

it submit form people can submit urls specific websites. php file within wordpress plugin

i tried script solution messing plugin scripts.js think. assume need add code in snippet:

$("#fep-submit-post.active-btn").on('click', function() {         tinymce.triggersave();         var title           = $("#fep-post-title").val();         var content         = $("#fep-post-content").val();         var bio             = $("#fep-about").val();         var category        = $("#fep-category").val();         var tags            = $("#fep-tags").val();         var pid             = $("#fep-post-id").val();         var fimg            = $("#fep-featured-image-id").val();         var nonce           = $("#fepnonce").val();         var message_box     = $('#fep-message');         var form_container  = $('#fep-new-post');         var submit_btn      = $('#fep-submit-post');         var load_img        = $("img.fep-loading-img");         var submission_form = $('#fep-submission-form');         var post_id_input   = $("#fep-post-id");         var errors          = post_has_errors(title, content, bio, category, tags, fimg);         if( errors ){             if( form_container.offset().top < $(window).scrolltop() ){             $('html, body').animate({ scrolltop: form_container.offset().top-10 }, 'slow'); }             message_box.removeclass('success').addclass('warning').html('').show().append(errors);             return;         } 

these 2 files use:

scripts.js

http://pastebin.com/4sfubhip

form.php

between ===>>>>> , <<<<====== input field need validated. below submit button. http://pastebin.com/g53hscu3

i this

<form onsubmit="return validator()">      <input type="hidden" name="post_id" id="fep-post-id" value="<?php echo $post_id ?>">      <button type="button" id="fep-submit-post" class="active-btn">go</button><img class="fep-loading-img" src="<?php echo plugins_url( 'static/img/ajax-loading.gif', dirname(__file__) ); ?>"/> </form>  <script type="text/javascript">     var validator = function(){         switch (variable) {             case "allowed":                 submit form;                 break;             default:                 return false;         }      } </script> 

returning false inside onsubmit attribute stop form submitting. gave basic example, using "allowed", have use string functions determine if base url 1 of trusted websites.

there better ways of doing - maybe using selects - little modification should achieve goal.


Comments