Simple Forms and Ajax
Posted on July 9, 2008So, I'm not seeing any good ways of returning a script block that can be executed on the client side. What i was doing was having a block of javascript validation code below my block of html form elements. I couldn't get this working, it may just not be possible, I'll try again later. However, you can put all of the javascript you need into the onclick event of a button. So trying that, I now have this, which isn't pretty, but my intentions are that the form would be autogenerated anyway, so I don't think I'll care about how pretty it is.
<form>
<table>
<tr>
<td>
<label>
First Name:</label>
</td>
<td>
<input type="text" id="FirstName" />
</td>
</tr>
<tr>
<td> </td>
<td>
<input type="button" value="Save" onclick="
if($('FirstName').value.length == 0){
alert('First Name is required!');
$('FirstName').activate();
return false;
};
" />
</td>
</tr>
</table>
</form>
| |
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
|