开发者

How do I make the form don't do anything at all if Submitted on blank?

开发者 https://www.devze.com 2023-01-30 15:38 出处:网络
How do I make don\'t do anything if a user clicks submit and he didn\'t write anything? I mean not show a message or 开发者_开发百科anything just don\'t do anything.

How do I make don't do anything if a user clicks submit and he didn't write anything? I mean not show a message or 开发者_开发百科anything just don't do anything.

I'm just starting to learn HTML and far from pulling off anything with PHP... I don't know how difficult is to do this so idk. Thanks for the help anyway

<textarea class="question-box" style="width:97%;" cols="20" rows="4"  id="question-box-' . $questionformid . '" name="title" onfocus="if(this.value == \'\'){this.value = \'\';}" onblur="if(this.value == \'\'){this.value = \'\';}"></textarea>

<table class=sample width=100% style="width:100%;">
<tr style="width:100%;">
<td width=480px>

<input type="hidden" class="ubicacion" style="width:60%; font-weight:bold; border-color:white; background:white; color:white" value="<?php the_search_query(); ?> " name="question" onfocus="if(this.value == \'\'){this.value = \'\';}" onblur="if(this.value == \'\'){this.value = \'\';}" /></p>


<form role="search" method="get" action="http://chusmix.com/" onsubmit="if (document.getElementById('s').value.length < 1) return false;">
...

The simplest solution possible that I'm aware of.

But remember, Javascript validation is only for the convenience of the user; it must always be double-checked on the server-side.


you need javascript. something like :

<script language="javascript">
function validateForm( form )
{
    result = false;
    //validate user input ...
    return result;
}
</script>
<form ... onSubmit='return validateForm( this );'>


You need form validation. While there are many ways to do this with Javascript may I suggest JQuery? This will enhance your HTML pages, though it will give you more to learn (which is good).

See here: http://bassistance.de/jquery-plugins/jquery-plugin-validation/

And look at the demos. If this does not suffice look at jquery form validation on Google.

0

精彩评论

暂无评论...
验证码 换一张
取 消