Click here to Skip to main content
15,888,401 members
Please Sign up or sign in to vote.
1.00/5 (2 votes)
See more:
i am trying to make month salary calculator.

i add multiple textboxes on button click . and i use datepicker on every textbox.
now i want compare all textboxes value to each other on another buttton click . if two or more textboxes values are match then alert should be show "same date not allowed".

how would i done this?
Help me thanx.
Posted
Comments
Sergey Alexandrovich Kryukov 17-Jan-16 12:13pm    
First of all, why? Use date pickers themselves, not text boxes. As to comparison, comparison of dates is just comparison of two points of time "rounded" to a day. What have you tried so far?
But do you want to do comparison on server side (C#) or client side (JavaScript)?
—SA
Harish-Sangwan 18-Jan-16 0:37am    
u also use date themselves.
Sergey Alexandrovich Kryukov 18-Jan-16 0:46am    
Who is "u"? Not clear what you mean. Please don't use "textspeak".
You did not answer my questions.
—SA
[no name] 17-Jan-16 13:00pm    
Go through below link:

http://www.c-sharpcorner.com/UploadFile/77a82c/compare-two-date-using-C-Sharp-and-jquery-date-picker/

1 solution

Hey hi,

You can do this using Jquery class,

Assign same class name to the textboxes you want to compare

Find the textbox having the class name in the jquery and compare for the value present
with other textbox.

Capturing the event for those textboxes different value in the textbox

Create functions for those textbox with that class name onblur,onfocusout,ontabout
refer below code, code me change as per syntex but the idea is to capture the change of any no of textbox which you want to compare

$('name*="abc"').on('blur','tabout','onfocusout')function{}

Declare a temp variable in jquery capture the value in the temp variable

every time the user changes the value compare the value with the previous value
once the value differs alert the user with the message "same data not allowed"


Basically the jquery function above selects all the elements having name abc, then captures the data on the above mentioned events for any of the textbox having class name similar to abc. If the value is different that other previous values it will throw alert.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900