• 0
Sign in to follow this  
Guest - Clow -

Checar Values Em Form Com Java!

Question

Guest - Clow -

Eu preciso fazer um <input type="text"> q só pode conter numeros, tem algum geito de fazerr isso com java?

Obs: O form não contem submit buttons só normal buttons!

Share this post


Link to post
Share on other sites

2 answers to this question

Recommended Posts

  • 0

Você pode fazer assim:

<!--
function somente_numero(campo){
	var digits="0123456789"
	var campo_temp 
	for (var i=0;i<campo.value.length;i++){
   campo_temp=campo.value.substring(i,i+1)	
   if (digits.indexOf(campo_temp)==-1){
      campo.value = campo.value.substring(0,i);
      break;
    }
	}
}

-->

no corpo da página coloque:

<input name="numero" id="numero" onKeyUp="javascript:somente_numero(this);" value="" size=15>

Share this post


Link to post
Share on other sites

Join the conversation

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

Guest
Answer this question...

×   Pasted as rich text.   Paste as plain text instead

  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.

Sign in to follow this