I'm including a portion of the code I use on form submittal. I have 2 radio buttons and a user must select one of these options or the form will not submit ( see green code) . I wrote a check to ensure that at least one radio is checked off or they get an error and it hightlights the radio boxes. This works fine , the first time. Once the submittal passes the checks I have put in it, the data is submitted via ajax and this resets most of the form , including unchecking the radio boxes ( shown in red) . The problem is that if a user wants to then submit another request via the form , even when they check off a radio box, it is not passing the "if not checked" code
Code:
if ( $("#scheduling_1").attr('checked') == false && $("#scheduling_0").attr('checked') == false ){
$("#scheduling_1,#scheduling_0").addClass('inputBG-error');
data1++
}
if(data1 > 0 ){
$("#control").removeClass('inputBG-error');
msg1.append("<div class='blk-border'><p class='red'>You have left some information blank.</p><p> Please fill out any fields highlighted in red and try again.</p></div>");
}
if(data1 > 0 ){
$("#submit-response").html(msg1).delay(250).show("slow");
return false
}
//Form submittal to server via Jquery .Ajax call begins here
var datastring = $('#rzrequestform').serialize();
$.ajax({
type: "POST",
url: "/Subwebs/Information Services/HelpDesk/rz/rzredzoneprocessUser.asp",
data: datastring,
success: function(html){
var tt= $(html).find("#hidden").text();
var msg = $("<div id='request-reply'></div>");
if ( $('#ticket').is(':checked')) {
msg.html("<div class='blk-border'><p>Your RedZone request has been submitted to the HelpDesk.</p><p class=\"red\"><strong>Your Redzone ID # is: "+tt+"</strong></p><p>You should save this number in case you would like to request any changes or updates to the notice you have requested.</p><p><a href='/Subwebs/Information Services/HelpDesk/scticket.asp'>Click here to open a web ticket also.</a></p></div>");
}
else {
msg.html("<div class='blk-border'><p>Your RedZone request has been submitted to the HelpDesk.</p><p class=\"red\"><strong>Your Redzone ID # is: "+tt+"</strong></p><p>You should save this number in case you would like to request any changes or updates to the notice you have requested.</p></div>");
}
$('input,textarea,#legend').removeClass('inputBG-error')
$(':input','#rzrequestform').not(":button, :submit, :reset, :hidden,[name='requestername'],[name='requesterusername']").val("")
$('#scheduling_1,#scheduling_0').removeAttr('checked');
$("#submit-response").html(msg).delay(250).show("slow");
},