Form fields stability php

How can I make fields still in the form fields after submitting the form and return with invalid input data?

 <form action="" method="post">
             <label for="cellPhoneNo">البريد الالكتروني</label>
                <input type="text" name="emailAddress" class="textField"/>
                <span>*</span>
                <span><?php 
                       if($emailValidator != CORRECT_VALUE)
                        echo $errorMessage[$emailValidator];?>
                </span>
                <br>

</form>

and here's where I check the input

 $emailValidator=checkInput($_POST['emailAddress'],INVALID_EMAIL_ADDRESS,'/^[a-zA-Z0-9._-]+@[a-zA-Z0-9.-]+.[a-zA-Z]{2,4}$/');

when user submit invalid email address, the validation result shows the error message to user. How can I make the invalid error email address still in the input?


add to input

 <input type="text" name="emailAddress" class="textField" value="<?  echo (isset($_POST) ? $_POST['emailAddress'] : "") ?>"/>

instead of "" you can insert your default value or just leave it like this :)


尝试,

<input type="text" name="emailAddress" value="<?php echo $_POST['emailAddress']; ?>" class="textField"/>


Try to use javascript to validate the email before posting it to your server-side code :)

Check this link: http://www.zparacha.com/validate-email-address-using-javascript-regular-expression/

链接地址: http://www.djcxy.com/p/69746.html

上一篇: Symfony中的验证器无效

下一篇: 表单字段稳定性php