N********n 发帖数: 8363 | 1 Say I use a textbox to collect several names separated by semicolons,
and then verify the input against an address book. Correct names will
have their font set to black underlined. Wrong ones will have their
font color turned to red.
Any Ajax.Net or jQuery hacks out there to simulate it? Have not done
this kinda front end stuff for a while. | a9 发帖数: 21638 | 2 用div+css吧。
【在 N********n 的大作中提到】 : Say I use a textbox to collect several names separated by semicolons, : and then verify the input against an address book. Correct names will : have their font set to black underlined. Wrong ones will have their : font color turned to red. : Any Ajax.Net or jQuery hacks out there to simulate it? Have not done : this kinda front end stuff for a while.
| s***o 发帖数: 2191 | 3 Just some brainstorming idea, I am not sure if there are already built-in or
short-cut ways of doing this:
Since a single textbox is used for all the names, it seems customizing the
validation engine is not a good way.
you could send the names to the server through jQuery ajax call, then parse
it and compare it with the address book, then return a List of the names
with extra information such as "IsCorrect" to the client.
Based on the "IsCorrect", you can apply different css styles to the names,
and concatenate them together, and then finally load it back into the
textbox.
Something like:
$.ajax({
type: "POST",
url: "[yourWebServiceMethodURL]",
data: "[theOriginalNameList]",
...
success: function (response){
// response contains the returned name list
var resultString = "";
for (var i = 0; i < response.length; i++){
var name = response[i].Name;
var status = response[i].IsCorrect;
var formattedName = [add styles to name based on status];
resultString += formattedName;
}
$("#yourTextBoxId").html(resultString); // or .val(...)?, couldn't remember
which one
}
...
});
btw, JSON.Stringify() is my favorite way to construct the data to be sent to
the server.
Or, if the address book is small, you can "get" it onto the client through
ajax call, and apply the comparison logic on client side. | a9 发帖数: 21638 | 4 I dont think a single input can do this.
or
parse
【在 s***o 的大作中提到】 : Just some brainstorming idea, I am not sure if there are already built-in or : short-cut ways of doing this: : Since a single textbox is used for all the names, it seems customizing the : validation engine is not a good way. : you could send the names to the server through jQuery ajax call, then parse : it and compare it with the address book, then return a List of the names : with extra information such as "IsCorrect" to the client. : Based on the "IsCorrect", you can apply different css styles to the names, : and concatenate them together, and then finally load it back into the : textbox.
| s***o 发帖数: 2191 | 5 it's fine with textarea
【在 a9 的大作中提到】 : I dont think a single input can do this. : : or : parse
| D******y 发帖数: 3780 | 6 SharePoint People Picker works like this. check out its HTML source?
【在 N********n 的大作中提到】 : Say I use a textbox to collect several names separated by semicolons, : and then verify the input against an address book. Correct names will : have their font set to black underlined. Wrong ones will have their : font color turned to red. : Any Ajax.Net or jQuery hacks out there to simulate it? Have not done : this kinda front end stuff for a while.
| n**********b 发帖数: 253 | 7 put all correct name in a span element and then add a class to the span
before return from Ajax call.
set the spam's css class in the client side. |
|