danielafnovo Posted June 11, 2013 at 02:10 PM Report #512038 Posted June 11, 2013 at 02:10 PM (edited) Boas, alguém me pode ajudar no código para validar apenas números? quero fazer a validação para o telefone, ja fui ver alguns códigos á net, mas não estou a conseguir...Obrigado 🙂 Edited June 11, 2013 at 03:15 PM by brunoais título muito melhorado.
pikax Posted June 11, 2013 at 02:11 PM Report #512040 Posted June 11, 2013 at 02:11 PM qual e' a tua duvida, tens bastantes topicos sobre isso, posta o que tens. Por muito mais que que estude só aprendo uma coisa, que ainda tenho muita coisa para aprender. A beleza de um código está em decompor problemas complexos em pequenos blocos simples. "learn how to do it manually first, then use the wizzy tool to save time." "Kill the baby, don't be afraid of starting all over again. Fail soon, learn fast."
nelsonr Posted June 11, 2013 at 02:12 PM Report #512041 Posted June 11, 2013 at 02:12 PM Talvez possas usar regular expressions http://stackoverflow.com/questions/5474088/php-regular-expression-filter-number-only
bioshock Posted June 11, 2013 at 02:29 PM Report #512051 Posted June 11, 2013 at 02:29 PM (edited) Podes fazer essa validação directamente no html. http://www.w3schools.com/tags/att_input_pattern.asp Edited June 11, 2013 at 02:29 PM by bioshock
I-NOZex Posted June 11, 2013 at 05:43 PM Report #512103 Posted June 11, 2013 at 05:43 PM Tens aqi um site com expressoes regulares, podes usar com o php ou com js: http://regexlib.com/ B2R » Beat2Revolution v3.0b | Regista e divulga-nos beat2revolution.net
yoda Posted June 11, 2013 at 07:14 PM Report #512123 Posted June 11, 2013 at 07:14 PM Foi discutido esse assunto á pouco tempo, e foi dada uma resposta. Faz uma pesquisa no fórum. before you post, what have you tried? - http://filipematias.info sense, purpose, direction
danielafnovo Posted June 12, 2013 at 06:23 PM Author Report #512454 Posted June 12, 2013 at 06:23 PM Olá, eu estava a exprimentar o pattern, e queria por para colocar os numeros dessa forma: xxx xxx xxx pattern="[0-9]{3}[0-9]{3}[0-9]{3} " fui pesquisar e achei coisas deste genero, algumas com barras, mas ainda assim nao funciona...
yoda Posted June 12, 2013 at 08:14 PM Report #512462 Posted June 12, 2013 at 08:14 PM O espaço é obrigatório ou opcional? before you post, what have you tried? - http://filipematias.info sense, purpose, direction
danielafnovo Posted June 12, 2013 at 08:19 PM Author Report #512463 Posted June 12, 2013 at 08:19 PM eu preferia com espaços ou então separado por traços...
yoda Posted June 13, 2013 at 12:04 AM Report #512498 Posted June 13, 2013 at 12:04 AM (edited) Para apanhar essa configuração com espaços ou hífens : #^[0-9]{3}(?:[-\s]{1})?[0-9]{3}(?:[-\s]{1})?[0-9]{3}$#uD Tem apenas em atenção que esta expressão vai validar se o input tem os caracteres autorizados, não vai validar o formato na íntegra (pois permite coisas como 222-222 222). Edited June 13, 2013 at 04:24 AM by yoda before you post, what have you tried? - http://filipematias.info sense, purpose, direction
danielafnovo Posted June 13, 2013 at 07:12 AM Author Report #512507 Posted June 13, 2013 at 07:12 AM eu exprimentei e dá-me erro , diz : "faça corresponder o formato pedido" , exprimentei : 999999999 , 999-999-999 ou 999 999 999...e deu sempre o mesmo erro :s
brunoais Posted June 13, 2013 at 07:48 AM Report #512511 Posted June 13, 2013 at 07:48 AM Nisso tens algum espaço antes ou depois desses numeros? "[Os jovens da actual geração]não lêem porque não envolve um telecomando que dê para mirar e atirar, não falam porque a trapalhice é rainha e o calão é rei" autor: thoga31 Life is a genetically transmitted disease, induced by sex, with death rate of 100%.
danielafnovo Posted June 13, 2013 at 10:17 AM Author Report #512530 Posted June 13, 2013 at 10:17 AM nao...
I-NOZex Posted June 13, 2013 at 10:56 AM Report #512548 Posted June 13, 2013 at 10:56 AM fiz o teste e aceita: 222-222-222, 222222222, 222 222 222 testei e 222.222.222 não dá... mostra o codigo que tas a usar para validar sfv B2R » Beat2Revolution v3.0b | Regista e divulga-nos beat2revolution.net
danielafnovo Posted June 13, 2013 at 11:21 AM Author Report #512564 Posted June 13, 2013 at 11:21 AM (edited) o código é este : <label> <b>Telefone :</b> <input class="design9" style="margin-left: 20px" value="xxx xxx xxx" onclick="this.value='';" onblur="javascript:if (this.value=='') {this.value='xxx xxx xxx'}" size="45" type="text" name="telefone" pattern="#^[0-9]{3}(?:[-\s]{1})?[0-9]{3}(?:[-\s]{1})?[0-9]{3}$#uD"> </label> Edited June 13, 2013 at 11:22 AM by danielafnovo
I-NOZex Posted June 13, 2013 at 11:36 AM Report #512578 Posted June 13, 2013 at 11:36 AM eu fiz o teste com o preg_match :| tambem ja reparei que as vezes com a mesma pattern, testando com php e com js, as vezes num funciona e noutro não :| com o php funciona, o que te sugeria entao era usares um "masked" input, e depois com o php mesmo validar com a pattern... B2R » Beat2Revolution v3.0b | Regista e divulga-nos beat2revolution.net
danielafnovo Posted June 13, 2013 at 12:18 PM Author Report #512604 Posted June 13, 2013 at 12:18 PM como assim? não percebi..
I-NOZex Posted June 13, 2013 at 02:43 PM Report #512665 Posted June 13, 2013 at 02:43 PM (edited) peço desculpa, ainda não estou muito familiarizado com o html5 xD ia sugerir usares um plugin js, mas esta pattern faz o que tu queres: \d{3}[\-]\d{3}[\-]\d{3} aceita numeros no formato xxx-xxx-xxx edit: tens aqui ainda melhor: \d{3}[\.\-\s]\d{3}[\.\-\s]\d{3} aceita: xxx xxx xxx, xxx-xxx-xxx e xxx.xxx.xxx \. > para aceitar pontos como divisão \- > para aceitar hifens como divisão \s > para aceitar espaços como divisão baseei-me por aqui: http://html5pattern.com/ Edited June 13, 2013 at 02:49 PM by I-NOZex B2R » Beat2Revolution v3.0b | Regista e divulga-nos beat2revolution.net
danielafnovo Posted June 13, 2013 at 05:18 PM Author Report #512726 Posted June 13, 2013 at 05:18 PM (edited) funcionou, muito obrigado.. Edited June 13, 2013 at 05:19 PM by danielafnovo 1 Report
I-NOZex Posted June 13, 2013 at 05:35 PM Report #512731 Posted June 13, 2013 at 05:35 PM 😉 dispoem B2R » Beat2Revolution v3.0b | Regista e divulga-nos beat2revolution.net
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now