jquery select all textboxes in a listview
I have a listview which is databound to X items. On a submit button click I would like to use jquery to go through the listview rows and do basic form validation. This validation isn't systems critical so I am not worried about someone manipulating or sending back malicious scripts. It is things like, you must have a firstname,lastname. So on and so forth.
Any ideas on how to do this in jquery without using the clientID (lvBob$ct10$txtName) would be great. Thank you very much
Sorry question seems to be a开发者_运维知识库 little ambigious
To eleberate I would like to iterate over X amount of rows with X amount of columns that are rendered in a listview. Validate each column based on my buisness logic and spawn an error message for each failure to validate.
Psuedocode
for each row in Listview
{
row.txt1 != null
{return "error message"}
}
But I would like to do this in jquery.
In order to get around selecting textboxes without referencing the ClientID of the ListView. First wrap the ListView in a div and then select based on all of the textboxes contained within that div.
The following code will iterate through each textbox using jQuery:
$('#myDiv input[type=text]').each(
function( intIndex ){
// Do processing here on each textbox using $(this)
}
);
You'll need to update the above code for your specific business requirements but it should get you started.
Have you googled it? First hit I got on google was this: How to select all textareas and textboxes using jQuery?
According to that link you can try the something like: $('li input[type=text]')
. If you need what type of data that is in the textbox you can add classes to the textboxes.
Figured it out. This jquery is what I used
$(this).find('input.firstName');
精彩评论