in a rails module, when user enters less than 0 value he should get invalid message.
in js file i have written a onchange function which expecting when a textbox gets less than zero value this function should trigger an alert.
$(document).on('onchange',".default-value" (function(event) {
e.preventDefault();
e.stopPropagation();
$('.default-value').each(function(){
var num = $(this).val();
if( num < 0)
alert("Invalid Entry");
});
});
in my slim.erb file i have written following code.in here the text box values are to be held and sent for the function i have written inside the js file.
= y.input :default_value, label: false, input_html: { class: "default-value #{ y.object.parameter.parameterize } " }
I expect an invalid error right when I type less than 0 value.
update with
$(".default-value").change(function(){
if($(this).val() < 0) {
$(this).val('');
alert("Invalid Entry");
}
});
Collected from the Internet
Please contact [email protected] to delete if infringement.
Comments