I'm using the jQuery validator plugin http://ift.tt/15JYAzL.
I have found that I can access elements in the form using either their ID or their name (at least with Firefox and Chrome). Is one way more correct and browser compatible than the other? Or maybe I should do something else altogether?
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>Testing</title>
<script src="http://ift.tt/18Zj3Di" type="text/javascript"></script>
<script src="http://ift.tt/1MZZCam" type="text/javascript"></script>
<script type="text/javascript">
$(function(){
$("#myForm").validate({
submitHandler: function(form) {
console.log('using id',form.myElementID.value);
console.log('using name',form.myElementName.value);
}
});
});
</script>
</head>
<body>
<form id="myForm">
<input type="text" name="myElementName" id="myElementID" />
<input type="submit" />
</form>
</body>
</html>
Aucun commentaire:
Enregistrer un commentaire