Jump to content

Telephone field format needs changing


xiabaili

Recommended Posts

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.

Link to comment
Share on other sites

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?

Link to comment
Share on other sites

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
Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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 by Digitizer
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.