Ver Mensaje Individual
  #1 (permalink)  
Antiguo 11/12/2015, 07:05
Avatar de ferdinandburgos
ferdinandburgos
 
Fecha de Ingreso: septiembre-2015
Ubicación: bogota
Mensajes: 10
Antigüedad: 8 años, 7 meses
Puntos: 0
valores numericos

Hola buenas tardes tengo este codigo y este me recive valores alfanumericos y quiero q solo me acepte valores numericos o q si escribo un valor q no sea numerico le salga un alert al usuario. soy nuevo en javascript... agradezco todas sus respuestas

jQuery(function($){
$('.cart').click(function(){

// Test to see if the price exceeds the minimum price (ie the Suggested Price):

if($('#minimum_price').length && parseFloat($('#minimum_price').val()) >= parseFloat($('input.name_price').val()))
{
alert('Please offer a price higher than the Minimum Price.');
return false;
}
// See if the price input is zero (because we want people to be able to choose a free option: NEEDS LOGIC FOR SET MINIMUM

else if(parseFloat($('input.name_price').val()) == 0)
{
return;
}

// Test to see if the input field has been left blank:

else if($('.name_price').length && !parseFloat($('input.name_price').val()))
{
alert('Por favor ingrese un valor numerico sin caracteres \n especiales y sin puntos ejemplo 250000');
return false;
}
// Test to see if input field is non-negative:

else if(parseFloat($('input.name_price').val()) < 0)
{
alert("Look here, old chap, that's just not on. Please enter a positive number, or zero. Tsk tsk.");
return false;
}

});
$('.cart').submit(function(){

$('<input name="price" />').val($('input.name_price').val()).attr('type',' hidden').appendTo($('form.cart'));
return;
});
});

Última edición por ferdinandburgos; 11/12/2015 a las 07:25