Click here to Skip to main content
15,906,708 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
XML
<?php
//$strVal = getInput("Please input a phone number : ");
echo"Please Enter Numbers Between 5-18 digits";
$strVal =$_GET["number"];
if (isset($strVal)) {
    $l = strlen($strVal);
    $strPhone = substr($strVal, $l, ($l - 4)) ."****";
    $NumberPrefix = substr($strVal, 0, ($l - 4));
    echo "<br />\n";
    echo "Masked Number is : ". $NumberPrefix.$strPhone;
}



?>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Simple PHP Form Demo</title>
</head>
<body>

  <form id="number" method="get" action="">
   <p><label>number: <br />
    <input type="text"  name="number" class="textfield" value="<?php echo htmlentities($NumberPrefix.$strPhone ); ?>" maxlength="18"/>
    </label></p>

    <p><input type="submit" name="submit" class="button" value="Submit" /></p>
    <script>document.form.reset();</script>
  </form>


</body>
</html>






above is my code to enter a telephone no and display same no. but masked.now two things that i need help with are
1.how to clear the data (entered by user in text area as well as on that echo statement) on refresh of browser
2.how to limit the minimum digits to 5

pls help guys....
Posted

1 solution

1. To clear the data there is an reset input type
HTML
<input type="reset">Clear</input>

To clear the echo message, set the innerHtml of the content to ""


But, validation should be done with client side, using javascipt/jquery/HTML5 validation. Not on server side.
See this[^]

Good Luck!
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900