Hey I'm using the onchange attribute or we they are called, and it wont vailidate in XHTML 1.0 Strict when using the w3c validater which i have to use, i need a way around this so that my code will still work, and validate. the error is: Line 211, Column 32: there is no attribute "onchange"
and here are the values it effects or w/e (not in proper order just cut and pasted)
Cost of Registration:<input id="cost" name="cost" readonly="readonly"/>
<p>
<input type="checkbox" id="monday" name="Attending" value="monday" />Monday<br />
<input type="checkbox" id="tuesday" name="Attending" value="tuesday" />Tuesday<br />
<input type="checkbox" id="wesnesday" name="Attending"value="wednesday"/>Wesnesday<b/></p>
i have another onchange that the validater seems to have no problems with
<p>
<select id="regcat" onchange="autofill()">
<option value="UWS Student">UWS Student</option>
<option value="Student at another institution">Student at another institution</option>
<option value="UWS Academic">UWS Academic</option>
<option value="Other UWS Staff">Other UWS Staff</option>
<option value="Academic from another Institution">Academic from another Institution</option>
<option value="Professional">Professional</option>
<option value="Retired">Retired</option>
</select>
</p>
Can find a fix for this anywhere.(sorry for grammar and spelling its very late)
You need to attach your event handler through JavaScript instead of the attribute. If you're using jQuery:
$('#regcat').change(autofill);
You'll want this in a document ready wrapper if you're not already using one. The shortest way:
$(function() {
$('#regcat').change(autofill);
});
If you're not using jQuery, you'll use the addEventListener method (but again, you'll need to account for the DOM being ready). If you're not using jQuery AND you need to support IE <9, you'll unfortunately have to also add in the attachEvent call within a conditional comment wrapper.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.