I have a form that uses a JQuery Validation plugin. It is working correctly, however the problem is that all fields are required and I would like to remove the "require" validation for some fields. Here is my javaScript
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script>
<script src="//cdnjs.cloudflare.com/ajax/libs/jquery-form-validator/2.1.47/jquery.form-validator.min.js"></script>
<script>
$.validate({
modules : 'sweden',
onModulesLoaded : function() {
$('input[name="Lan"]').suggestSwedishCounty();
$('input[name="Ort"]').suggestSwedishMunicipality();
}
});
</script>
I am aware that I can change the "rules" and even custom the error message, but how would it look like and more importantly: Where would I put it? Here is my form:
<form action="<?php echo $editFormAction ?>" id="minForm">
<INPUT TYPE=button VALUE="Tillbaka till patienter" onclick=window.history.back()>
<h3>Skapa person</h3>
<p>
<strong>Personnummer:</strong> <br />
<input name="Personnummer" id="Personnummer" data-validation="swesec" data-validation-use-hyphen="true">
</p>
<p>
<strong>Namn:</strong> <br />
<input name="Namn" id="Namn" data-validation="alphanumeric" data-validation-allowing="åäö">
</p>
<p>
<strong>Efternamn:</strong> <br />
<input name="Efternamn" id="Efternamn" data-validation="alphanumeric" data-validation-allowing="åäö">
</p>
<p>
<strong>Kön:</strong><br />
<select name="kon">
<option value="NULL">Välj</option>
<option value="Man">Man</option>
<option value="Kvinna">Kvinna</option>
</select>
</p>
<strong> Län</strong> <br />
<input name="Lan" id="Län" data-validation="swecounty">
</p>
<p>
<strong>Ort</strong> <br />
<input name="Ort" id="Ort" data-validation="swemunicipality" >
</p>
<p>
<input type="submit">
</p>
<input type="hidden" name="MM_insert" value="form2"/>
</form>
Thank you...
我相信这就像删除元素中的data-validation
标签一样简单,这在我的代码中起作用,我也使用它。
So when there is something is should be correct? If that is the case, i dont know how to do that. You might ask yourself what the function is.
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.