2016-02-29 41 views
0

你好,我有一個osclass網站,我做了這個代碼需要進行一些自定義字段HTML5自定義屬性所需的消息不工作

<script type="text/javascript"> 
     $("#countryId").attr('required', 'required'); 
     $("#regionId").attr('required', 'required'); 
     $("#city").attr('required', 'required'); 
     $("#cityArea").attr('required', 'required'); 
     $("#contactName").attr('required', 'required'); 
     $("#price").attr('required', 'required'); 
</script> 

請幫我更改默認的消息:「請填寫此場」

非常感謝您

+1

HTTP的可能重複:// stackoverfl ow.com/questions/25628209/dynamically-change-required-for-html5-input-control – arthurakay

+2

[設置自定義HTML5必填字段驗證消息]的可能重複(http://stackoverflow.com/questions/13798313/set-custom -html5-required-field-validation-message) – PeeHaa

回答

0

我認爲這將有利於 <input type="text" required title="Custom message" />

+0

只需將title屬性添加到輸入元素 –

+0

那麼您可以像這樣通過jQuery使用 –

+0

$('#countryId')。 attr(「標題」,「自定義消息」); –