In my wordpress blog comment form, my default value for the visitor's URL field is "Website (optional)". When the textbox is clicked, the value is cleared. However, if the visitor does not enter anything in the textbox, the form passes the default value, being "Website (optional)" as the visitor's URL. My problem is that I'm trying to NOT pass this default value if nothing is entered. Here's what I've done (NOT WORKING!): <form action="<?php echo get_option('siteurl'); ?>/wp-comments-post.php" method="post" id="commentform" onSubmit="ClearDefaultURL()"> HTML: For the javascript, I have: function ClearDefaultURL() { if ($_POST["url"] == "Website (optional)") $_POST["my_field"] = ""; } HTML: I was thinking this would not pass the default value, but it still is. Any suggestions on how to fix this???
What you're doing here? This is php or javascript? You must know the id of the website field. Assuming that the id is 'website' : function ClearDefaultURL() { var input = document.getElementById('website'); if (input.value == "Website (optional)") input.value = ""; return true; } Code (markup): <form action="<?php echo get_option('siteurl'); ?>/wp-comments-post.php" method="post" id="commentform" onSubmit="return ClearDefaultURL()"> HTML: