I am wondering if there is a way to show a title box containing a message when you click a button,or as a better example,you have an input,and after php script evalute the value,and it's wrong,a title box will show up , saying "Wrong" ... Any ideas? Just with php if its possible!!
EDIT: What i am looking for,is not for a simple message like:
echo '<p></p>';
Of course i know how to do that,its basic... I was just wondering if a TITLE box can show up,like this:
<input type=text title='Wrong'>
but after the value its evaluated...
You could achieve this by setting a GET or POST value with the button:
html:
<form method="post">
<input type="hidden" name="postvalue" value="yes">
</form>
php:
<?php
if(isset($_POST['postvalue'])){
echo "<p>messageboxtoshow</p>";
}
?>
however a solution with javascript would work way better and would look way more userfriendly, and this only works on page refresh.
Try this sample one
<?php
if(isset($_POST['submit'])){
echo "<p> Your message</p>";
}
?>
<form action=<?php $_SERVER['PHP_SELF']?> method="post" >
<input type="submit" name="submit" value="submit">
</form>
Do you mean validation per input field? You can use JQuery for that.
I made a fiddle to give you a visual idea: http://jsfiddle.net/4b3tzreo/
For example, if this is your form:
<div class="container">
<div class="left">
Username
</div>
<div class="right">
<input type="text" name="username" id="username" />
</div>
</div>
<div class="container">
<div class="left">
Password
</div>
<div class="right">
<input type="password" name="password" id="password" />
</div>
</div>
<div class="container">
<div class="left">
<button id="submit">Submit values</button>
</div>
</div>
You can add a class to it when the input value is empty, like this:
$('#submit').click(function(){
var username = $('#username').val();
var password = $('#password').val()
if(username === '') {
$('#username').addClass('error');
alert('username is not filled');
}
if(password === '') {
$('#password').addClass('error');
alert('password is not filled');
});