excuse me, well, i just want to ask if it's possible to highlight the textbox and display its error in php or if not, is there any way that i can do to make it possible but still with php?.. can somebody pls tell me how? thanks a lot!
:) God Bless!
excuse me, well, i just want to ask if it's possible to highlight the textbox and display its error in php or if not, is there any way that i can do to make it possible but still with php?.. can somebody pls tell me how? thanks a lot!
:) God Bless!
Yes, you can. If you mean on submit, you can. But just stand alone, no. This is just a simple example of course
<?php
if(isset($_POST['id'])) {
$input = $_POST['id'];
if (preg_match('/[^0-9]/', $input)) {
$error['id'] = 'Id contained non numbers';
$bad_style = "style='border: 1px solid red;'";
}
}
?>
<html>
<body>
<form name='test' action='' method='post'>
<input name='id' <?php if(isset($error['id'])) echo $bad_style; ?> type='text' />
<input type='submit' />
</form>
<?php
if(isset($error)) {
echo "Error:";
foreach($error as $key) {
echo "$key </br>";
}
}
?>
</body>
</html>
Very crude, but it is do able depending on what you want to do.
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.