此表单验证在wordpress插件中不起作用



此表单验证代码在wordpress插件中不起作用,表单直接提交,就好像onsubmit事件根本不存在一样。请帮忙

<?php
/**
 * Plugin Name:....
 * Description:.....
 * Version: Pre release
 * Author:....
 * Author URI:....
 **/
add_action("admin_menu", "create_menus");
function create_menus()
{
 add_menu_page("cash Details", "cash Details", 4, "form-page", "cash_deals_form_page");
}
function cash_deals_form_page()
{
?>
<script>
    function validateForm() {
        var x = document.forms["myForm"]["clientName"].value;
        if (x == "") {
            alert("Name must be filled out");
            return false;
        } else {
            return confirm('Do you really want to submit this entry?');
        }
    }
</script>
<div style='display:inline-block; width:48%;'>
    <form name="myForm" method='post' onsubmit="return validateForm()" action="<?php echo $_SERVER['REQUEST_URI'];?>">
        Client Email (Type the Email Id of the client whom you want to allot cash):
        <br/>
        <input type='text' id='input1' name='clientName' maxlength='100'>
        <br/>
        <br/> Type the cash to be added in the client's account:
        <br/>
        <input type='number' id='input2' name='cash' min='-10000' max='100000000'>
        <br/>
        <br/> Type your comments here (optional):
        <br/>
        <textarea rows='4' cols='60' name='adminComment' maxlength='500'></textarea>
        <br/>
        <br/>
        <input type='submit' name='submit'>
        <br/>
    </form>
</div>
<?php
}
?>

我发现了问题,事实证明validateForm()是wordpress中的预定义函数,只需更改该名称即可解决问题!!!!!

相关内容

  • 没有找到相关文章

最新更新