ボタンクリックで作動する機能を作ろうとしています。クリックすると、関数は各入力 type=text 要素をループし、値属性を variable に割り当てます。その場合、 variable = null または variable = "" メソッド confirm('are you sure you want to save a blank row') を呼び出します。ここに私のコード/疑似コードがあります:
<script type="text/javascript">
function isInputEmpty() {
$("#btnSave").click(function(){
$('input[type=text]').each(function(){
var x = $(this).attr('value');
var bool = false;
if(x == null || x == "")
{
bool = true;
}
else
{
send the request
}
if(bool == true)
{
if(confirm('Are you sure you want to save a blank URL?'))
{
send the request
}
else
{
do nothing or cancel the request
}
}
else
{
send the request
}
}
}
</script>
これが私のASPボタンコードです:
<asp:Button ID="btnSave" runat="server" Text="Save"/>
さらに詳しい情報が必要な場合は、お知らせください。前もって感謝します