valores numericos
Publicado por ferdinand burgos (2 intervenciones) el 11/12/2015 14:54:43
Buenas tardes soy nuevo en javascript quisiera q en este codigo poder agregar un alerta para cuando los usuarios ingresen un valor q no sea numerico. Agradezco sus respuestas
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
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;
});
});
Valora esta pregunta


0