xiabaili Posted August 24, 2014 Share Posted August 24, 2014 Hi guys, first and foremost I’m not a programmer, but I do have a little problem that I need help with. I have a website and there is a members registration form, within this form there is a Telephone field. The telephone field requires a certain format e.g. 138 xxxxxxxxx, I would like your help on how to change the format, so that I can input random numbers. where and how should I be editing this field to achieve the required result? Thanks in advance. Quote Link to comment Share on other sites More sharing options...
Ch0cu3r Posted August 24, 2014 Share Posted August 24, 2014 where and how should I be editing this field to achieve the required result? How would we know that? We are not sat in front of you. Quote Link to comment Share on other sites More sharing options...
xiabaili Posted August 24, 2014 Author Share Posted August 24, 2014 How would we know that? We are not sat in front of you. I’m not a programmer, that’s why I’ve thrown this question out to get some sort or response, I was hoping on something a little more constructive. I’ve registered on numerous websites that have formatted registration fields, how many ways can this be done? Javascript, php? I was hoping for someone to tell me where to begin looking, as I’ve said, I am not a programmer, and I’m on here trying to fix a problem. Maybe I should rephrase my question: If you were to design a form and format an address field, how would you do it? Quote Link to comment Share on other sites More sharing options...
ginerjm Posted August 24, 2014 Share Posted August 24, 2014 Maybe you should show the code so that we can help you identify how the formatting is occurring now and then we can help you remove it. That's pretty constructive. Quote Link to comment Share on other sites More sharing options...
Digitizer Posted August 24, 2014 Share Posted August 24, 2014 Everyone is right here, they do not have that chunk of code to explain.. anyway, let say you somehow found where it needs to be changed and you saw that there is a form field with <input></input> just change its value to be as follows <input type="text" name="whatevert it could be" value="138"></input> //thats the best I can do without having your code Quote Link to comment Share on other sites More sharing options...
ginerjm Posted August 24, 2014 Share Posted August 24, 2014 To elaborate on digitzer's post - if you find the <input> tag that has a name attribute that suggests it is for the phone number entry, remove any associated picture attribute that is part of that tag. That would be one way it is being forced to a certain format. In fact html 5 puts out a message on screen when the user tries to enter something that doesn't fit the picture. If otoh there is no picture clause, you'll need to look thru php code for that input tag's 'name=' value and see what php is doing with the input value to enforce formatting. Quote Link to comment Share on other sites More sharing options...
Digitizer Posted August 24, 2014 Share Posted August 24, 2014 (edited) Ok, as you are saying if you were to build a form yourself, and check for number format correctly, Here is how I would do it using PHP only, anyway, i doubt that to understand even what I am going to write, you will need to understand PHP, but I am here to help, so will I <?php if(isset($_POST['submitForm'])){ $phNum = $_POST['phoneNumber']; // Lets first check its validity // We wanted it to start from 138 and have 16 numbers lets say //Check length first (if it not 12, throw error else keep on) $phNumLength = strlen($phNum); if($phNumLength != '12'){ die("You have given " . $phNumLength . "numbers. It must be 12. Please go back and change"); } //Check format (it must start from 138) $phNumFormat = substr($phNum,0,3); if($phNumFormat != '138'){ die(" Your phone Number is in wrong format, e-g it is starting from " . $phNumFormat . ". It must be starting from 138 "); } // If these two conditions are met, the code will continue to do its job // further on } ?> <form name="myForm" method="post" action="<?php echo $_SERVER['PHP_SELF']; ?>"> <input type="text" name="phoneNumber" placeholder="138xxxxxxxxx" /> <input type="submit" name="submitForm" /> </form> Well, if you have any more questions about this?? Well, if you have any more questions about this?? Edited August 24, 2014 by Digitizer Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.