Jump to content

second textbox value is greater than first textbox display alert using javascript


ksumanth

Recommended Posts

Hello everyone,

 

I have a form, In that i have two textboxes

1. Total amount

2. Paid amount

if second textbox value is greater than first textbox then i should display alert and the textbox should empty using javascript or jquery.

 

can any one help me

Thanks

Sumanth

Just so you know, jQuery is javascript, just written in a nice way.

 

you'll basically want to grab the values for the two text boxes, similar to this (using jQuery):

 

var firstBox = $('#first_text_box').val()
var secondBox = $('#second_text_box').val()

Then you'll use a simple if statement to compare the values, and perform some action (alert) if the second is greater than the first

 

if(secondBox > firstBox){
  alert("Some message");
}

 

Hopefully that'll get you started.

 

Denno

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.