I am trying to cancel a form submit on an add page if the fields don’t validate
I am trying to do this:
$(‘#fdns_recordsadd’).on(‘submit’, function(e) {
if(!/[1]+$/.test($(‘#x_name’).val())){
$(this).val(‘’);
// e.stopPropagation();
e.preventDefault();
return false;
}
});
Such that if the “name” field is not the character types I want, then I null the field and dont submit the form.
However while it seems to null the field it still submits the add form.
A-Za-z0-9- ↩︎