In Javascript it could be something like:
Code:
<script language="JavaScript1.5" type="text/javascript">
function telNbr(tlphnbr){
var tlphSliced = new Array();
tlphSliced[0] = tlphnbr.value.slice(0,3);
tlphSliced[1] = tlphnbr.value.slice(3,6);
tlphSliced[2] = tlphnbr.value.slice(6);
}
</script>
The slice function in Javascript does not include the last character. As an example:
String "hello world"
slice(0,4) would result in "hell", that is, characters 0, 1, 2 and 3 (remember Javascript start numbering from 0, not from 1)
in PHP, it could be something like this:
Code:
<?php $telNbr=array;
$telNbr['0']=substr($_POST['name_of_text_field'],0,2);
$telNbr['1']=substr($_POST['name_of_text_field'],3,5);
$telNbr['2']=substr($_POST['name_of_text_field'],6);
?>
If your method is not post, but get, substitute $_POST for $_GET.
The function substr does include the last character. Same example as before
substr('hello world', 0, 4) would result in "hello", that is, characters 0, 1, 2, 3 and 4
Be aware that there is not error handling here, so if someone keys something like 124 instead a full telephone number, you won't get an error but it will not work.
Hope this helps.