Jump to content

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


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

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

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

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  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.

×
×
  • 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.