如果表单已验证,请打开警告框

时间:2017-10-27 10:18:36

标签: javascript html

如果表单已经过验证,我想打个确认框。这是我的代码:

我使用webshim / pollyfill进行验证

SpanishModel

-

<script src="js-webshim/polyfiller.js"></script>
<script type="text/javascript" src="js/custom.js"></script> 
<script>
   $.webshims.polyfill('forms');    
</script>

在此版本中,即使表单为空,也会打开框。你能帮帮我吗?

1 个答案:

答案 0 :(得分:0)

&#13;
&#13;
<script>
function myFunction(){
var message = document.getElementById('input').value
if(message){
  alert("me")
}
}
</script>
<form id="form">
	<label class="control-label col-sm-3" for="inputSuccess3">Paket:</label>
	<div class="col-sm-9">
		<select class="form-control" id="Paket" name="paket">
		</select>
	</div>

	<label class="control-label col-sm-3" for="inputSuccess3">Miktar:</label>
	<div class="col-sm-9">
		<input class="form-control" type="number" id="adet" name="adet" min="20" max="250" value="20" required>
	</div>

	<label class="control-label col-sm-3" for="inputSuccess3">Link:</label>
	<div class="col-sm-9">
		<input id="input" class="form-control" type="text" name="link" required>
	</div>

	<div class="col-sm-offset-4 col-sm-8">
		Ücret: <span id="output">40</span> Kredi
	</div>
	<div class="col-sm-offset-3 col-sm-9">
		<button type="submit" class="btn btn-primary" onclick="myFunction()">Gönder</button>
	</div>
</form>
&#13;
&#13;
&#13;